Author eyadams
Recipients docs@python, eyadams
Date 2021-06-08.04:13:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623125616.73.0.892905550694.issue44344@roundup.psfhosted.org>
In-reply-to
Content
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.`"
History
Date User Action Args
2021-06-08 04:13:36eyadamssetrecipients: + eyadams, docs@python
2021-06-08 04:13:36eyadamssetmessageid: <1623125616.73.0.892905550694.issue44344@roundup.psfhosted.org>
2021-06-08 04:13:36eyadamslinkissue44344 messages
2021-06-08 04:13:36eyadamscreate