Python Forum

Full Version: pow function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
Operator precedence implies that
>>> (-2) ** 1/3 == ((-2) ** 1)/3
True
which is different from (-2) ** (1/3)