Hi everybody this is my first time on the community.
Hope not to bother anybody with silly questions.
I noticed that doing many operations with Double or Float
variables returns imprecise results.
I created this simple code as example:
FileWrite(filehandle,"D O U B L E V A R I A B L E");
for (x=0.05; x<=10; x=x+0.05) FileWrite(filehandle," ",x);
FileWrite(filehandle,"F L O A T V A R I A B L E");
for (y=0.05; y<=10 ; y=y+0.05) FileWrite(filehandle," ",y);
If math hasn’t become an opinion yet, the code above
shouldn’t give numbers like:
for the Double variable and:
for the Float variable.
Notice that both “for” loops are terminated one iteration
10.00000000000001 is greater than 10
10.00002 is greater than 10.
Other two things to notice from this code (if I’m not asking
too much) is the two annoying warnings from MetaEditor:
y=0.05 ----> Truncation of constant variable.
Possible loss of data due to type conversion.
It seems that metaeditor is confusing Float type with
Thanks a lot in advance for your helpfulness and patience.
you must use NormalizeDouble() function.
there is a good article that covers that topic on mql4 site:
Thank you for the hint Investeo
Could you tell me what's going on here?
why the output is still 8.050000000000001 ??
Also does anybody knows why I'm having the following warnings from MetaEditor: