note 89844 deleted from language.operators.arithmetic by danbrown

From: Date: Wed, 25 Mar 2009 18:26:09 +0000
Subject: note 89844 deleted from language.operators.arithmetic by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152439@lists.php.net to get a copy of this message
Note Submitter: urkoben at hotmail dot com ---- Stranget things happens: $a=450.00+450.65+564.50+185.95; $b=1651.10; var_dump($a); var_dump($b); echo ($a==$b?"true":"false")."<br>"; returns: float(1651.1) float(1651.1) true I try correcting with floatval() and dividing by 1, but nothing worked. I supose it is for the floating point. The solution i found is: $a=450.00+450.65+564.50+185.95; $b=1651.10; $a+=$b; $a-=$b; var_dump($a); var_dump($b); echo ($a==$b?"true":"false")."<br>"; returns as expected: float(1651.1) float(1651.1) true

« previous php.notes (#152439) next »