How come, when I round up decimals some numbers gets wrong
echo round(0.7125, 2);
Will result in: 0.71
BUT:
echo round(0.935625, 2);
Returns: 0.93999999
Why is that?
I´m using: 5.5.45-MariaDB
How come, when I round up decimals some numbers gets wrong
echo round(0.7125, 2);
Will result in: 0.71
BUT:
echo round(0.935625, 2);
Returns: 0.93999999
Why is that?
I´m using: 5.5.45-MariaDB
You are using a comma ,
instead of a dot .
for the decimal separator. Use :
echo round(0.935625, 2); => 0.94
Ok it seems that this is an issue of floating point precision. You are asking the system to display 0.94
which the system can't represent as a float
. So it displays the nearest number it can display: 0.93999999
echo round(0.935625, 2); // there is comma instead of .
Please remove comma (,)
and try it