Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58570 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86729 invoked from network); 4 Mar 2012 13:52:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2012 13:52:28 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:44558] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/9A-12048-893735F4 for ; Sun, 04 Mar 2012 08:52:25 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id A8C62700043A; Sun, 4 Mar 2012 13:52:20 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id 9NWy9WZV8zew; Sun, 4 Mar 2012 13:52:20 +0000 (WET) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 1DFC57000436; Sun, 4 Mar 2012 13:52:20 +0000 (WET) Received: from damnation.nl.lo.geleia.net (damnation.nl.lo.geleia.net [IPv6:2001:470:94a2:4:4866:11bc:1688:8089]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 53BEE2005414; Sun, 4 Mar 2012 13:52:18 +0000 (WET) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net, "Anthony Ferrara" References: Date: Sun, 04 Mar 2012 14:52:14 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/11.61 (Win32) Subject: Re: [PHP-DEV] Patches for Review From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Sun, 04 Mar 2012 14:29:49 +0100, Anthony Ferrara wrote: > I had messaged about these patches before, but with the 5.4 release > process happening I think it slipped through the cracks. I have 3 > patches that are ready for inclusion... >> [...] > > https://bugs.php.net/bug.php?id=60789 > Bringing pow() inline with docs in that it will attempt to return an > integer (by casting one or more of the arguments to int) if possible. > This fixes a precision loss that can occur with float arguments that > are exactly integers on 64 bit platforms. > > [...] This doesn't seem right. It's overly clever. It's like saying that 4.0 + 1 should return int(5) and not float(5.). Or perhaps a closer analogy would be: if we're in a 64-bit platform (only then can integers have a larger precision than doubles); if one of the operands is exactly an integer; if the other operand is a float exactly representable as an integer (perhaps a large power of 2), but its accuracy is negative (where accuracy is the 15.9546 - log10(abs(x)), or, informally, the effective number of digits to the right of the decimal point); if the result of the sum is exactly representable as a 64-bit integer; then return such integer. It's easy to see these sort of tricks would have to be applied all over the place (additions, products, and all other mathematical operations). In sum, I think the rule that if a mathematical operation involves a float, the result should be a float ought to be kept. -- Gustavo Lopes