So I understand that FMOD
gives some wacky answers sometimes because its sort of approximate.
But even given that I'm struggling to utilize the answers it throws up later-on in the code.
For instance, fmod(16,1.6)
gives us 1.6 rather than 0, that's fine. In the following code, echoing $goodfit
prints 1.6 but hurray doesn't print.
$getLength = 16;
$goodFit = fmod($getLength, 1.6);
echo $goodFit;
if ($goodFit === 1.6){
echo hurray;
}
I've tried double equation signs instead of triple incase it was a data type problem and I've tried rounding the $goodfit
equation to one decimal place.
All seems a little odd.
I'm just trying to make a bit of code that triggers if a division was exact.
question from:
https://stackoverflow.com/questions/65906333/fmod-in-php-results-not-being-seen-as-equal-to-their-float-equivalent 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…