Re: Power function as operator

From: Date: Fri, 22 Nov 2013 22:47:52 +0000
Subject: Re: Power function as operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-70301@lists.php.net to get a copy of this message
On Fri, Nov 22, 2013 at 5:27 PM, Chris London <me@chrislondon.co> wrote: > 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 > > > > > Unfortunately no, > > https://www.google.com/search?q=-3+%5E+2 > > What it is doing is -(3 ** 2). If you want +9 you'd have to do (-3) ** 2 > That's actually partly wrong. To clarify it's not -(3**2) it's ~(3**2), which is very different. ~9 is -10 (the compliment of 9). So ~3**2 can be broken down into (3**2) // which is 9 ~(9) // which is -10

« previous php.internals (#70301) next »