I try intval(6.02 * 100)
,the result is 602。but why the result of intval(5.02 * 100)
is 501?
Asked
Active
Viewed 64 times
1 Answers
3
This is a floating point math issue. The following might help explain it:
ini_set('precision', 17);
echo (float)5.02;
5.0199999999999996
echo 5.02 * 100;
501.99999999999994
echo intval(501.99999999999994);
501
More discussion on this topic: php intval() and floor() return value that is too low?

But those new buttons though..
- 21,377
- 10
- 81
- 108