[issue43830] (-1) ** 0.5 returns (6.123233995736766e-17+1j) instead of 1j

Serhiy Storchaka report at bugs.python.org
Tue Apr 13 09:03:06 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

It is the same "gotcha" as

>>> math.cos(math.pi/2)
6.123233995736766e-17

You can expect that cos(π/2) is exactly 0, but floating point value math.pi is only an approximation of the π number. The difference between math.pi and exact value of π leads to non-zero result of cos(math.pi/2).

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43830>
_______________________________________


More information about the Python-bugs-list mailing list