Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58574 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92643 invoked from network); 4 Mar 2012 14:02:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2012 14:02:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.173 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.173 mail-qy0-f173.google.com Received: from [209.85.216.173] ([209.85.216.173:33303] helo=mail-qy0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/EB-12048-2F5735F4 for ; Sun, 04 Mar 2012 09:02:26 -0500 Received: by qcsc20 with SMTP id c20so1457592qcs.18 for ; Sun, 04 Mar 2012 06:02:23 -0800 (PST) Received-SPF: pass (google.com: domain of ircmaxell@gmail.com designates 10.224.182.201 as permitted sender) client-ip=10.224.182.201; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ircmaxell@gmail.com designates 10.224.182.201 as permitted sender) smtp.mail=ircmaxell@gmail.com; dkim=pass header.i=ircmaxell@gmail.com Received: from mr.google.com ([10.224.182.201]) by 10.224.182.201 with SMTP id cd9mr1035976qab.92.1330869743594 (num_hops = 1); Sun, 04 Mar 2012 06:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=e1AJPs8f9cfBZYmTvl94Gog7Gtg64NV5A9RYa8xsr6o=; b=SyucNS1niWNCxKPrwwVK2oys1kDe4CE5HSdvijnjnZhdB3Qfg+pJsXoDQ+d7L9526P s0wHCx2Cn0k0BMtqP92qWKFoVo641UxHGtdC2xtuy6pgjWEQkjbnpHaztJbhWJRq+Ohi aI4Sc+In8i6FrlKB2ELBMIKsCUJrOFZYpESj4BTV/uE8OT0hq2phoSCQlGanpNSdC7/F b/lYnJ/hkyRQulD2JfxbYORgHgi4X0O9bwcZrCyAaRohrwCzka0xhrytukJ2yxaKvbV7 xhV5M5GMwaGOGR65DmtQ5aYMtKpPW/Kqf66B95fQy8WibYPPZmgVaN4j2ta9KFX8+Dou XNsA== MIME-Version: 1.0 Received: by 10.224.182.201 with SMTP id cd9mr928895qab.92.1330869743554; Sun, 04 Mar 2012 06:02:23 -0800 (PST) Received: by 10.229.49.74 with HTTP; Sun, 4 Mar 2012 06:02:23 -0800 (PST) In-Reply-To: References: Date: Sun, 4 Mar 2012 09:02:23 -0500 Message-ID: To: Pierre Joye Cc: Gustavo Lopes , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Patches for Review From: ircmaxell@gmail.com (Anthony Ferrara) >> In sum, I think the rule that if a mathematical operation involves a float, >> the result should be a float ought to be kept. > > Yes, it is a must. Well, I'm not so sure about that. If you look at the docs of pow(), it describes the return type as "base raised to the power of exp. If the result can be represented as integer it will be returned as type integer, else it will be returned as type float.". That's not the current behavior. pow((float) 2, 1) returns float(2). If you want to update the docs instead of the code, then that's fine. However, this can lead to precision loss in a number of cases (like pow(2, (float) 55) which is not representable exactly by a float, and hence cause data-loss. Whereas converting to an integer allows (on 64 bit platforms) an exact representation. I'm not suggesting changing addition to follow these rules, but to bring pow() into alignment with the documentation. And I think because of the nature of pow(), the likelihood that you'll have precision loss is a lot higher than other areas... But if the sentiment is strong against it, then an update of docs is in order... Additionally, I thought the whole point of type juggling in PHP was such that the type didn't matter? So that a float and an int are the same from a usage standpoint? But this is a case where the exact same input (just type is different) leads to different output. Which I believe is inconsistent and incorrect. But if the consensus is otherwise, that's fine... Anthony