somebody can explain me why this code:
$a = 0.1;
$b = 0.2;
if ($a + $b == 0.3) {
echo "OK";
} else {
echo "KO";
}
returns KO?
I don't understand why the sum result is different the float 0.3, considering that:
var_dump($a + $b);
returns: float(0.3)
The only hypothesis I have is that the comparison is made between only $b and 0.3 but the doubt remains because also in this case:
if ( ($a + $b) == 0.3) {
I get KO..
Aucun commentaire:
Enregistrer un commentaire