Re: Power function as operator
| From: | Sherif Ramadan | Date: | Fri, 22 Nov 2013 23:03:32 +0000 |
| Subject: | Re: Power function as operator | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70302@lists.php.net to get a copy of this message | ||
> On Fri, Nov 22, 2013 at 3:17 PM, Niel Archer <spam-free@blueyonder.co.uk
> >wrote:
>
> > Hi,
> >
> >
> > > So:
> > > -3 ** 2 == -9
> >
> > Shouldn't this be +9
> >
> >
>
To add to this note, the negation operator in PHP is left-associative,
whereas the patch here makes ** right-associative. So the result is
expected to be -9 and not 9 given the static scalar expression should be
evaluated as -(3**2) based on operator associativity.