Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70762 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16514 invoked from network); 19 Dec 2013 21:50:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2013 21:50:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.175 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.214.175 mail-ob0-f175.google.com Received: from [209.85.214.175] ([209.85.214.175:64552] helo=mail-ob0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/1C-42949-C3A63B25 for ; Thu, 19 Dec 2013 16:50:52 -0500 Received: by mail-ob0-f175.google.com with SMTP id uz6so1827680obc.6 for ; Thu, 19 Dec 2013 13:50:49 -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=g1nWFHk4U9Aun4/hZtK7eQf9Jxwamtm4rAyNrleQlHA=; b=qXSLEd77DKlA2//thMCSNWuD/gy0p28HRUZl6M2qkTRYkrSnGyPXWv4ShIfk1JlTb/ jWbVttECGLWnwW29t79DNun4+BwgeOzf64LxI6gjJZVd1g+UGETUP+CjKmtyjRKxY72j crH5vv8ER+2re6yXqGHNCQBQKLbbvCDDIJh2pMBmx7LBD6izWTy4kWnFZNLFkmBkgiI7 IhOFaX/hLA6ky1c7IVawVUUzPuuG6xZtgGnKgUD340wZ9/z7stA5Srk6hrqZLAJMDyEH AI16TYkYTWyo3Eq7MHGK7f+JmTRFkBxa2b1udqd/rEOU7ajsELW9wfqyPvn9As+r8QWR 8+9A== MIME-Version: 1.0 X-Received: by 10.60.35.194 with SMTP id k2mr3236873oej.42.1387489849189; Thu, 19 Dec 2013 13:50:49 -0800 (PST) Received: by 10.182.221.170 with HTTP; Thu, 19 Dec 2013 13:50:48 -0800 (PST) In-Reply-To: References: Date: Thu, 19 Dec 2013 13:50:48 -0800 Message-ID: To: Daniel Lowrey Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0112cb56972c9904edea2751 Subject: Re: [PHP-DEV] Re: power operator (again) From: kris.craig@gmail.com (Kris Craig) --089e0112cb56972c9904edea2751 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Dec 19, 2013 at 4:33 AM, Daniel Lowrey wrote: > > Thanks for all your effort! Unfortunately, since there's no option for > > negative numbers to intuitively square to positive outcomes, my vote is > > still No. I understand and respect your reasoning even though I do not > > agree with it. > > To me this is not a question of "intuitive" vs. "unintuitive" ... -3^2 = -9 > is how the preponderance of credible resources evaluate the expression. As > far as I can tell voting "no" on this basis is equivalent to me claiming > the earth is flat because it better fits my world-view. That's a faulty analogy. In mathematics, the square of any number, positive or negative, yields a positive result. Any scientific or graphing calculator will match that behavior. I did sqr(-3) in the Windows Calculator just now and it outputted 9, not -9. From http://en.wikipedia.org/wiki/Square_(algebra): "One of the important properties of squaring, for numbers as well as in many other mathematical systems, is that (for all numbers x), the square of x is the same as the square of its additive inverse -x. That is, the square function satisfies the identity x2 = (-x)2. This can also be expressed by saying that the squaring function is an even function." Now, I understand why some programming languages behave differently from the algebraic standard. I don't agree with it, but I understand their reasoning. Claiming that "the squaring function should always be an even function" is the equivalent of saying that the Earth is flat is faulty because it completely ignores the facts that support that argument, just as it would be faulty for me to ignore the facts that support yours. I believe that, especially for a KISS language like PHP, our top priority with math operators should be to match arithmetic laws as closely and as intuitively as possible. The average PHP developer is going to do -3 ** 2 and expect a result of 9, not -9, and rightly so I think. You're free to disagree and you certainly have valid reasons for doing so, but please try to keep in mind that there is a valid argument on the other side of this, as well. --Kris --089e0112cb56972c9904edea2751--