Re: INF behavior
| From: | Derick Rethans | Date: | Fri, 27 May 2011 14:48:53 +0000 |
| Subject: | Re: INF behavior | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52520@lists.php.net to get a copy of this message | ||
On Thu, 26 May 2011, Scott MacVicar wrote:
> On 26 May 2011, at 20:03, Philip Olson <philip@roshambo.org> wrote:
>
> > Hello geeks,
> >
> > A geek is needed to clarify PHP bug #45712. This is an edge case but the test
> > (bug45712.phpt) contains code similar to the following:
> >
> > <?php
> > $inf = pow(0, -2);
> >
> > var_dump($inf); // float(INF)
> > var_dump($inf == $inf); // bool(false)
> > var_dump($inf === $inf); // bool(true)
> > ?>
> >
> > That's how it's behaved since ~forever (AFAICT) and remains in 5.3.7-dev, but
> > PHP 5.4.0-dev changes behavior so both now return true.
> >
> > Is this is how we want it? And how should this be documented/explained?
>
> I think I changes this :-)
>
> It didn't make sense that == and === produce different results.
>
> Though if someone has a better understanding of maths then we can fix it.
I think it does make sense. == is the equal operator, and INF is not
equal to INF (just like SQL NULL is not equal to NULL). However, they
are identical (like you can test in SQL with NULL IS NULL).
cheers,
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug