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.06.07
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.05.18
Hey everyone, I wanted to create a function for risk management as seen in the code below.
After sending 0.01 as the risk percentage and 1.5 for the SL Multiplier, the code seems to work fine. However, when observing the optimalLotSizeRounded variable with Comment() during visual EA backtesting, the determined lot size sometimes does not get set to a round number, i.e. 0.4200000000001. This happens rarely though and has not been an issue for sending orders so far, but after selecting trades with "OrderLots()==" for partial closes later on, the EA cant seem to access these non round numbers. I saw a few posts on this board advising to stay away from "NormalizeDouble()", so I tried to use "MathRound()" by employing "MarketInfo" to convert the lots into an integer to be able to round this number and then convert it back into a double.
If anyone knows why the "MathRound()" sometimes (rarely) returns a double with so many decimal places I would greatly appreciate your help! Also I apologize if the code is bad, I'm new to programming and this snippet is a combination of two tutorials and some own attempts at coding.