Re: NAN and INF cast to int
| From: | Yasuo Ohgaki | Date: | Thu, 02 Jan 2014 19:55:39 +0000 |
| Subject: | Re: NAN and INF cast to int | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70967@lists.php.net to get a copy of this message | ||
Hi Robert,
On Fri, Jan 3, 2014 at 3:36 AM, Robert Stoll <php@tutteli.ch> wrote:
> An example:
> $f = NAN;
> var_dump(++$f); // float NAN
> var_dump((float) NAN); // float NAN
> var_dump((int) NAN); // int -2147483648 -> what?
> var_dump((bool) NAN); // bool true -> makes sense
>
> $f = INF;
> var_dump(++$f); // float INF
> var_dump((float) INF); // float INF
> var_dump((int) INF); // int 0 -> what?
> var_dump((bool) INF); // bool true -> so why int 0?
> var_dump((int) (bool) INF); // int 1
>
I've added this to the RFC as an issue.
https://wiki.php.net/rfc/comparison_inconsistency
BTW, this issue could be mitigated by GMP float support.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net