1

I try intval(6.02 * 100),the result is 602。but why the result of intval(5.02 * 100) is 501?

Cœur
  • 37,241
  • 25
  • 195
  • 267
jaychen
  • 123
  • 7

1 Answers1

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?