2

Why does this code:

echo (int)((0.1+0.7)*10);

Return 7?

Is this because of some weird approximation algorithm of math operations in php causing 0.1+0.7 to be almost 0.8 and not exact 0.8?

It confuses me because any other decimal value returns correct answer like with 0.1+0.8 and so on and so on.

0 Answers0