Bizarre arithmetic results

Terry Reedy tjreedy at udel.edu
Thu Feb 11 17:52:05 EST 2010


On 2/11/2010 11:23 AM, Jussi Piitulainen wrote:
> Robert Kern writes:
>> On 2010-02-11 06:31 AM, Shashwat Anand wrote:
>>> There is a little issue here that '>>>  -.1 ** .1' should give you
>>> error message. That is it.
>>
>> No, fractional powers of negative numbers are perfectly valid
>> mathematically. The result is a complex number. In Python 3 (what
>> the OP is using), this has been implemented, but not in Python 2.6.
>
> Perhaps it should raise a MisleadingSpacingError at compile time.

You forgot the smiley ;-).

 > The error message could recommend - .1**.1, or better -(.1 ** .1).

The compiler would never see the difference between -.1 ** .1 and the 
first and probably no difference with the second either.





More information about the Python-list mailing list