Question about 'double' in Print.log

Back to topics list To post a new topic, please log in or register
rfb 2016.05.09 01:54

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. 

GumRai 2016.05.09 02:35 #
Show your code. Explain what you are expecting and what is the result
rfb 2016.05.09 03:07 #
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.
WHRoeder 2016.05.09 03:17 #
rfb: unknown to me how that number is translated into the decimals,
The number, translated into decimal was 680791842979692216.0.
rfb 2016.05.09 03:26 #

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.


WHRoeder 2016.05.09 14:01 #
6.807918429796922e+016 < 16.807918429796922e+016; Just as 6 < 16
6.807918429796922e+017 > 16.807918429796922e+016; Just as 60 > 16
rfb 2016.05.09 17:20 #
WHRoeder, Thank You.
Back to topics list  

To add comments, please log in or register