[issue46444] Wrong value of pi for larger values using math.cos() function

Mark Dickinson report at bugs.python.org
Thu Jan 20 03:10:48 EST 2022


Mark Dickinson <dickinsm at gmail.com> added the comment:

Hi Darshan. This isn't a bug in Python. You're running into the limitations of floating-point arithmetic.

There's a lot of good material on those limitations available on the web, starting with Python's own tutorial: https://docs.python.org/3/tutorial/floatingpoint.html

If you want to understand what's going on in this particular case, take a closer look at the values of 90 - 180/k when k=2**62 and k=2**63, say. Are they the same? Should they be? Why / why not?

----------
nosy: +mark.dickinson
resolution:  -> not a bug
status: open -> closed

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


More information about the Python-bugs-list mailing list