Message395339
[Dennis]
> I think the relevant property is that the exponent is not an integer
Yep: the delegation to complex pow kicks in after handling infinities and nans, and only for strictly negative base (-0.0 doesn't count as negative for this purpose) and non-integral exponent.
Here's the relevant code: https://github.com/python/cpython/blob/257e400a19b34c7da6e2aa500d80b54e4c4dbf6f/Objects/floatobject.c#L773-L782
To avoid confusion, we should probably not mention fractions like `1/3` and `4/3` as example exponents in the documentation, since those hit the What-You-See-Is-Not-What-You-Get nature of binary floating-point. Mathematically, `z^(1/3)` is a very different thing from `z^(6004799503160661/18014398509481984)` for a negative real number `z`, and the latter is what's _actually_ being computed with `z**(1/3)`. The advantage of the principal branch approach is that it's continuous in the exponent, so that `z^(1/3)` and `z^(6004799503160661/18014398509481984)` only differ by a tiny amount. |
|
Date |
User |
Action |
Args |
2021-06-08 16:20:04 | mark.dickinson | set | recipients:
+ mark.dickinson, docs@python, Dennis Sweeney, eyadams |
2021-06-08 16:20:04 | mark.dickinson | set | messageid: <1623169204.19.0.515385919207.issue44344@roundup.psfhosted.org> |
2021-06-08 16:20:04 | mark.dickinson | link | issue44344 messages |
2021-06-08 16:20:04 | mark.dickinson | create | |
|