Re: [RFC] Saner string to number comparisons
| From: | Arnold Daniels | Date: | Wed, 15 Jul 2020 15:11:48 +0000 |
| Subject: | Re: [RFC] Saner string to number comparisons | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111022@lists.php.net to get a copy of this message | ||
Hi Nikita,
One of the problems with numeric string comparisons is that it might
interpret a hexadecimal value as scientific notation
$red = '990000';
$purple = '9900e2';
$red == $purple; // true
I suggest only interpreting a number formatted with a sign ("1e+100") or
with decimals ("1.0e100") as scientific notation as part of this RFC. These
are the notations that languages use when casting a float to a string,
never "1e100"
PHP "1.0E+100"
JavaScript "1e+100"
Python "1e+100"
Ruby "1.0e+100"
Java "1.0E100"
Arnold