rounding numbers

 

How do you round a number to 2 decimal places in MQL4?

MathROund only does it to integers and has no input fordecimal places?????

 

short answer is: just use NormalizeDouble(dVal,2)

the function looks at the third decimal digit and if >= 5 then propagate round up leftwards.

ie, this function ONLY ever rounds starting from the,int Digits)'th + 1 digit position.

eg, 1.125 -> 1.13 as expected. But 1.1245 -> 1.12, because the 4, in Digits+1 position is <5

IF you interested in digits 4,5,6,... propagating leftwards then you must do other stuff. I not know about that stuff. But NormalizeDouble() and me = good friends and anyway, you can so easily test out yourself by using Print(...) in quicky script.

hth

btw SM, have you read the MQL Book?

many of the questions you been rapidly posting here are ALL covered...

Reason: