strtod and NaN vs. zero
| From: | Marc Bennewitz | Date: | Sun, 23 Oct 2016 10:55:57 +0000 |
| Subject: | strtod and NaN vs. zero | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-96556@lists.php.net to get a copy of this message | ||
Hi internals,
On casting a non numeric value to a float in PHP the result will be float(0).
In PHP-7.0 an exception was introduced that on casting a string "/\s*NaN\s*/i" will result in float(NaN).
https://3v4l.org/2Xakm
Wouldn't it be more logical and expected to return NaN in all cases of casting a non numeric string to a floating point number?
Thanks
Marc