Download MetaTrader 5

!PRECISION ERRORS IN DIVISION!

To add comments, please log in or register
gianks
33
gianks  

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

Wackena
648
Wackena  

Try this:

MathAbs(879) / 10

or,

NormalizeDouble(MathAbs(879) / 10, 1)



Slava
Moderator
6939
Slava  
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
To add comments, please log in or register