Float numbers
| From: | franciscusk at tiscali dot it | Date: | Sat, 18 Nov 2017 17:26:56 +0000 |
| Subject: | Float numbers | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-26578@lists.php.net to get a copy of this message | ||
By this, I would like to set before you the next problem:
I have a script in which is present the comparison "if ($a == $b) {...},
where $a = "4e2" and $b = "4d2", both strings, so the answer should be "false".
I have two computers, on the first one is still active PHP 4.2, on the other one PHP 5.5.
At my surprise, under PHP 4.2 the answer is "true", but under PHP 5.5 "false".
It took me quite some time to figure out that PHP takes "4e2" as a float number (400),
but that only PHP 4 takes also "4d2" as a float number (again 400), and thus considers the equality as "true"
(however, it does not when one uses "===", since the type is "string", not "float").
So, PHP 4 takes still in account the use of "d" in the sense of "decapower", alias for "e" and for that reason equal, PHP 5 does not.
My question is: can you confirm that this is true, and above all, from which version of PHP the decapower is not recognized anymore?
Thanks! Frans Kok