Message395305
https://docs.python.org/3/library/functions.html#pow
The built-in pow() function will return a complex number if the base is negative and the exponent is a float between 0 and 1. For example, the value returned by `pow(-1, 1.0/3)` is `(1.0000000000000002+1.7320508075688772j)`
The answer is mathematically correct, but `-2.0` is also mathematically correct. There is nothing in the documentation currently to suggest that a complex number might be returned; in fact, given the statement "[with] mixed operand types, the coercion rules for binary arithmetic operators apply", one might reasonably expect `-2.0` as the answer.
I suggest the following sentences be added to the end of the second paragraph:
"If `base` is negative and the `exp` is a `float` between 0 and 1, a complex number will be returned. For example, `pow(-8, 1.0/3)` will return `(1.0000000000000002+1.7320508075688772j)`, and not `-2.0.`" |
|
Date |
User |
Action |
Args |
2021-06-08 04:13:36 | eyadams | set | recipients:
+ eyadams, docs@python |
2021-06-08 04:13:36 | eyadams | set | messageid: <1623125616.73.0.892905550694.issue44344@roundup.psfhosted.org> |
2021-06-08 04:13:36 | eyadams | link | issue44344 messages |
2021-06-08 04:13:36 | eyadams | create | |
|