Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52517 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21806 invoked from network); 27 May 2011 09:27:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 May 2011 09:27:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:56781] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/B2-25602-C7E6FDD4 for ; Fri, 27 May 2011 05:27:25 -0400 Received: by qwi4 with SMTP id 4so885973qwi.29 for ; Fri, 27 May 2011 02:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=5Pive48te9kIMDUAU83nic+k+qiCHvSyJmqQ9a623MQ=; b=HQ4YGkLpFOtnwPGeuUxY1omRIVOccZ+/1ibr/AW99hBKcQRyDi1MDWNVwctkJOQqHX KKfTJ9QvX7z3ssked5lMET4W44Bvjqq/NerUSNDy3nxWJNkkO4arwGSeL30ViupX4lUT u71M+isvIIzZYTabfc/Pybpf8SVYkAi1w/Kuw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=jBocyl/5aYYs2cWEcIM5hcuQwWx8lwuxEmUTyCUdUuav+FCCzT0jPchVaFiaDOzGqD 3FyqX8s4dcnjV6NyAFHUt4uvKZ9sWSAi+0IuteAm1cIrDKVtwnplfILa80rqnfBtgtF0 3ycIb84vI7gctA+NxFW6MD94EcZGJp3JLogdI= Received: by 10.229.131.23 with SMTP id v23mr1457605qcs.11.1306488442507; Fri, 27 May 2011 02:27:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.85.137 with HTTP; Fri, 27 May 2011 02:27:02 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: <2EFE9027-13EA-4570-B6D2-2C56D85C7DAE@macvicar.net> Date: Fri, 27 May 2011 10:27:02 +0100 Message-ID: To: Ferenc Kovacs Cc: Scott MacVicar , Philip Olson , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] INF behavior From: rquadling@gmail.com (Richard Quadling) On 27 May 2011 08:17, Ferenc Kovacs wrote: > On Fri, May 27, 2011 at 6:10 AM, Scott MacVicar wrot= e: > >> On 26 May 2011, at 20:03, Philip Olson wrote: >> >> > Hello geeks, >> > >> > A geek is needed to clarify PHP bug #45712. This is an edge case but t= he >> test (bug45712.phpt) contains code similar to the following: >> > >> > > > $inf =3D pow(0, -2); >> > >> > var_dump($inf); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// float(INF) >> > var_dump($inf =3D=3D =C2=A0$inf); // bool(false) >> > var_dump($inf =3D=3D=3D $inf); // bool(true) >> > ?> >> > >> > That's how it's behaved since ~forever (AFAICT) and remains in 5.3.7-d= ev, >> 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 =3D=3D and =3D=3D=3D 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=3D=3Dinf, but inf !=3D=3D 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=3D=3Dnull && null=3D=3D=3Dnull, why can't $inf=3D=3D$inf && $inf=3D= =3D=3D$inf php -r "var_dump(PHP_VERSION, NF, INF=3D=3DINF, INF=3D=3D=3DINF, NULL, NULL=3D=3DNULL, NULL=3D=3D=3DNULL);" 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=3D=3DINF and INF=3D=3D= =3DINF, just as NULL=3D=3DNULL and NULL=3D=3D=3DNULL 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 =3D=3D=3D should return true. I think 5.4.0-dev has it right. As long as -INF !=3D INF && -INF !=3D=3D IN= F (which I'm sure is right). Of course, if you come from SQL, any comparison to NULL always fails. Even to other NULLs. --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea