Precidence of unary plus/minus relative to exponentiation

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Thu Apr 3 10:56:35 EST 2003


Oops.  Again it appears that I was typing with my brain off....  

-G

> -----Original Message-----
> From: Mikael Olofsson [mailto:mikael at isy.liu.se]
> Sent: Wednesday, April 02, 2003 2:45 AM
> To: python-list at python.org
> Subject: Re: Precidence of unary plus/minus relative to exponentiation
> 
> 
> On Tue, 1 Apr 2003 12:40:21 -0500
> "Warnes, Gregory R" <gregory_r_warnes at groton.pfizer.com> wrote:
> > The current operator precedence places unary plus and minus higher
> > than exponentiation.  This leads the counterintuitive result:
> > 
> > 	>>> -2.0**2.0
> > 	-4.0
> > 	
> > Python's operator predicence is causing this to be interpreted as:
> > 
> > 	>>> -(2.0**2.0)
> > 
> > rather than the normal mathematical precidence, which would give
> > 
> > 	>>> (-2.0)**2.0
> > 
> > Is there a good reason for the Python order of precedence?
> 
> I would say that the behaviour is what I expect. I would never expect
> -2.0**2.0 to mean (-2.0)**2.0. Nobody I've met in a 
> mathematical context
> (engineers and mathematicians) have ever assumed your interpretation.
> Where have you seen that interpretation?
> 
> /Mikael
> 
> --------------------------------------------------------------
> ---------
> E-Mail:  mikael at isy.liu.se
> WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael               
> Phone:   +46 - (0)13 - 28 1343
> Telefax: +46 - (0)13 - 28 1339
> 
>          /"\
>          \ /     ASCII Ribbon Campaign
>           X      Against HTML Mail
>          / \
> 
> This message was sent by Sylpheed.
> --------------------------------------------------------------
> ---------
> Linköpings kammarkör: www.kammarkoren.com
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.





More information about the Python-list mailing list