Download MetaTrader 5

Question about 'double' in Print.log

To add comments, please log in or register
RFB
127
RFB  

I got in the '.log' file with 'Print()' and on screen from 'Comment()', number with double like this: 6.807918429796922e+016. I got the value without the decimals with 'DoubleToStr(,1)' as: 680791842979692216.0. 

My problem, and because it's kind of unknown to me how that number is translated into the decimals, I was comparing further that number with other numbers but without the 'DoubleToStr()', and I expected to get some other numbers with bigger value, but nothing happened (note: Possible coincidence).

Question: If compared that kind of numbers with '>' or '<', will be got the correct result during calculations?

 P.S. I don't know how to reproduce that similar numbers and to check what I ask. 

Keith Watford
Moderator
10070
Keith Watford  
Show your code. Explain what you are expecting and what is the result
RFB
127
RFB  
GumRaiShow your code. Explain what you are expecting and what is the result
GumRai, it is a bit a longer file over 20k, I could attach it, but it will be of no use if I post it, it is kind of optimizer code script, and just once I got that number and with Only 1 pair-symbol, just 1 hour before. And it was as result in chain calculating, so hardly I believe it could be reproduced. I am just asking as an example in comparing :
void OnStart() {
 double sum_1 = 6.807918429796922e+016;
 double sum_2 = 16.807918429796922e+016;
 if(sum_1 < sum_2) Print("-- yes");
 if(sum_1 > sum_2) Print("-- no");
 if(sum_1 == sum_2) Print("-- why?");
}
I did this in test script, but I don't know if such thing is correctly written. It prints 'yes', ie. correctly. But first time using to write this king of numbers in MQL4, so I don't know if the method of initializing that values like that is common method in mql4. Just that is my question.
whroeder1
15085
whroeder1  
rfb: unknown to me how that number is translated into the decimals,
The number, translated into decimal was 680791842979692216.0.
RFB
127
RFB  

Hi WHRoeder, thank You. But what I am confused is: as the code example I wrote up, if those 2 double numbers are got while calculating (ie. not initialized like that), and compared further, will it give correct comparing result same as like those initialized? And also, I am not sure which number is bigger.. :(. By no computer logic 2-nd, but I am not sure in this case.

Thanks. 

whroeder1
15085
whroeder1  
6.807918429796922e+016 < 16.807918429796922e+016; Just as 6 < 16
6.807918429796922e+017 > 16.807918429796922e+016; Just as 60 > 16
RFB
127
RFB  
WHRoeder, Thank You.
To add comments, please log in or register