Re: Re: [vote] pow-operator

From: Date: Thu, 19 Dec 2013 02:38:19 +0000
Subject: Re: Re: [vote] pow-operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
>
> >> That said, if there are other reasons for voting 'no' besides
> >> associativity, feel free to shoot me an email or discuss it on the list.
> >
> > What did it for me was the lower precedence for the unary minus.  I don't
> > want to have another language that thinks a negative number squared is a
> > negative number.  I understand and respect your reasoning as outlined in
> > the RFC, but this is a deal-breaker for me.
>
> I've had a short discussion with Anthony about this and he convinced me
> that I was indeed wrong about my "unary minus" reasoning; therefore I have
> updated the RFC to reflect that. So:
>
> echo -3 ** 2; // 9
> echo 1 - 3 ** 2; // -8
>
> The unary minus is now at the same level as [, the array dereferencing
> operator.
>

We should follow the mathematic precedence rules; -3 ** 2 should be -9.

Note that "-3^2" as input to Mathematica, Matlab and Google search engine
all gave -9 as the answer, *as mathematically expected*.


Thread (15 messages)

« previous php.internals (#70739) next »