Round up number
-
Hello everybody.
I want to round up some number. For example:
1.2389 to 1.24 (2 decimal)
1.2389 to 1.239 (3 decimal)I use DoubleToString(variable,2) and it just cut out the number, not round up the number.
Please help. Thanks in advance and have a nice day . . . . -
https://www.mql5.com/en/docs/math/mathfloor
MathFloor() rounds the number to the nearest integer below. We can use it together with some basic maths:
(MathFloor(1.2389*100)+1)/100 = 1.24
(MathFloor(1.2389*1000)+1)/1000 = 1.239
edit: oh, its probably bit easier with https://www.mql5.com/en/docs/math/mathceil
-
This is very useful to me. Thank you very much