On 21/04/2008, John Fouhy <[EMAIL PROTECTED]> wrote:
>  >>> -1 ** (1.0/2.0)
>  -1.0

Replying to myself:

It turns out that all is not what it seems.  Let's try again:

>>> (-1)**0.5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: negative number cannot be raised to a fractional power

So, to revise my answer, for math.pow(x,y) or x**y, python will refuse
negative values of x.  This might not be mathematically perfect, but
you get what you pay for, I guess.

Furthermore, python evaluates "-x**y" as "-(x**y)" which is why it
seemed to give correct answers.

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to