I was trying to validate if the first floating number could be fully divided by the second floating number and I got something like these:
$first = 10.20; // or 5.10, 7.14, 9.18
$second = 1.02;
var_dump(fmod($first, $second));
// output is showing
float(1.02)
But if I try to divide below these numbers by 1.02 fmod()
works nicely.I don't understand whyfmod()
behaving like this? Any answer to this question will help me to understand the fact.
$first = 4.08; // or 2.04, 3.06, 6.12, 8.16
$second = 1.02;
var_dump(fmod($first, $second));
// output is showing
float(0)