MQL5: Wrong results in simple operations with the double type. It's quite serious

 

   double a = 0.3; 

   double b = 0.1;
   
   Print(a/b);

-----------------------------

2.9999999999999996


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


double a = 0.0003;

Print (a * 10000);

-----------------------------

2.9999999999999996

 

Floating-point has an infinite number of decimals. It's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)