Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pow function
#1
hi,
I met a problem when using the built-in function pow().
here is the code:
In [1]: pow(-2, 1/3)
Out [1]: (0.6299605249474367+1.0911236359717214j)
In [2]: (-2) ** 1/3
Out [2]: -0.6666666666666666
The document says pow(x, y) is equivalent to x ** y, but it is different here.
Why??
I use python3.6, anaconda Spyder.
Reply
#2
Operator precedence implies that
>>> (-2) ** 1/3 == ((-2) ** 1)/3
True
which is different from (-2) ** (1/3)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020