Monday, March 20, 2017

Impossible to round or truncate decimal Laravel

I have a problem in my Controller in Laravel 4. I try to round (or truncate) a decimal with 2 digits after comma, but it doesn't work.

I tried something like this :

round(888/100, 2);

Or :

floor(888*100)/100;

But I have 8.880000000000001 instead of 8.88. Why?

(In this example I take this number but it can be an other number)



via K4tn1x

Advertisement