Re: Re: power operator (again)

From: Date: Thu, 19 Dec 2013 22:38:33 +0000
Subject: Re: Re: power operator (again)
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-70771@lists.php.net to get a copy of this message
On 19/12/13 22:34, Sanford Whiteman wrote:
- (3**2) is simply not the same as (- 3)**2 but '-3' should always be (-3) the space has a significance in this case as far as I am concerned.
But it doesn't... the - is just another operator (even in "real math") and doesn't have the highest precedence, space or not. What's fascinating is that some portion of devs have been making assumptions for years and years and only now is there an case that requires consensus -- since the (wrong) assumption still ends up with the right results ~100% of the time given the current precedence table and other math rules.
It suddenly strikes me that in high school algebra class, we do not learn that -2² = 4, because that's -(2²) = 4, which is obviously wrong. You'd actually write (-2)² = 4. So I'm really confused now as to why people think -2 ** 2 should equal 4. -2² is -4. Why should -2**2 equal 4? -- Andrea Faulds http://ajf.me/

« previous php.internals (#70771) next »