Why in PHP language, the code below prints 7
?
print (int) ((0.1+0.7) * 10)
While
print (int) ((0.1+0.8) * 10)
prints 9
?
Why in PHP language, the code below prints 7
?
print (int) ((0.1+0.7) * 10)
While
print (int) ((0.1+0.8) * 10)
prints 9
?
You need to use round() function while converting float values
print (int) round((0.1+0.7) * 10);