On 27 May 2011 08:17, Ferenc Kovacs <i...@tyrael.hu> wrote: > On Fri, May 27, 2011 at 6:10 AM, Scott MacVicar <sc...@macvicar.net> wrote: > >> On 26 May 2011, at 20:03, Philip Olson <phi...@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. >> >> S >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > https://twitter.com/#!/SaraMG/status/73903500198821888 > @PhilipOlson If anything it should be: inf==inf, but inf !== inf. After all, > not all infinities are the same, but they are all infinite. > > and I agree with Sara on this one. > > Tyrael >
I wonder if INF is really any different to NULL. If null==null && null===null, why can't $inf==$inf && $inf===$inf php -r "var_dump(PHP_VERSION, NF, INF==INF, INF===INF, NULL, NULL==NULL, NULL===NULL);" string(9) "5.3.7-dev" float(INF) bool(false) bool(true) NULL bool(true) bool(true) I think of NULL and INF as states (no value assigned vs the ultimate value assigned). You can't really determine the value only the nature of the value. And the nature of INF is INF, so INF==INF and INF===INF, just as NULL==NULL and NULL===NULL So, when you compare them, you can't compare the value (in the traditional sense), just the states and the states are the same both, so === should return true. I think 5.4.0-dev has it right. As long as -INF != INF && -INF !== INF (which I'm sure is right). Of course, if you come from SQL, any comparison to NULL always fails. Even to other NULLs. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php