RE: [PHP-DEV] strtod and NaN vs. zero
| From: | Anatol Belski | Date: | Mon, 24 Oct 2016 13:54:31 +0000 |
| Subject: | RE: [PHP-DEV] strtod and NaN vs. zero | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96594@lists.php.net to get a copy of this message | ||
Hi Marc,
> -----Original Message-----
> From: Marc Bennewitz [mailto:dev@mabe.berlin]
> Sent: Sunday, October 23, 2016 12:56 PM
> To: PHP Internals List <internals@lists.php.net>
> Subject: [PHP-DEV] strtod and NaN vs. zero
>
> 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
>
It is a BC breaching bug and was fixed https://bugs.php.net/bug.php?id=73329 . Cast of
string to number is always zero, a way to change it would cause another BC breach which IMHO were
not worthwhile.
Regards
Anatol