!PRECISION ERRORS IN DIVISION!

 

Hi.

i'm experiencing a very strange problem with division between doubles.

If i try do divide a double just rounded via MathRound by 10, often i obtain a precision error:

Ex:

879.0 / 10 = 87.9000000001

980.0 / 10 = 97.9999999999

164.0 / 10 = 16.4


Nothing wrong in multiplication (1.10 * 10 = 11.0 correct! ).


I have tested this behavior in two separated environment with same results.


Regards Gianluca

 

Try this:

MathAbs(879) / 10

or,

NormalizeDouble(MathAbs(879) / 10, 1)



 
Documentation on MQL5: Language Basics / Data Types / Real Types (double, float)
  • www.mql5.com
Language Basics / Data Types / Real Types (double, float) - Documentation on MQL5
Reason: