This question already has an answer here:
- Compare floats in php 17 answers
I'm having very strange problem.. My code is below:
$pRate = (double)str_replace(array("x+(x*", "/100)"), "", $p['formula']); // Formula = x+(x*22.5/100)
for($i=20;$i<=30;$i+=0.5){
if($pRate == $i) echo "exists";
}
Why doesn't this code print "exists"? I checked the variable types with gettype. They are bot double. I printed all variables but 22.5 == 22.5 doesn't work?
Aucun commentaire:
Enregistrer un commentaire