note 89844 added to language.operators.arithmetic
| From: | urkoben at hotmail dot com | Date: | Wed, 25 Mar 2009 18:24:03 +0000 |
| Subject: | note 89844 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152438@lists.php.net to get a copy of this message | ||
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
----
Server IP: 130.206.1.5
Probable Submitter: 81.39.108.81
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/89844
Del: integrated -- https://master.php.net/note/delete/89844/integrated
Del: useless -- https://master.php.net/note/delete/89844/useless
Del: bad code -- https://master.php.net/note/delete/89844/bad+code
Del: spam -- https://master.php.net/note/delete/89844/spam
Del: non-english -- https://master.php.net/note/delete/89844/non-english
Del: in docs -- https://master.php.net/note/delete/89844/in+docs
Del: other reasons-- https://master.php.net/note/delete/89844
Reject -- https://master.php.net/note/reject/89844
Search -- https://master.php.net/manage/user-notes.php