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

2022-01-20 Thread Darshan Kanade
Darshan Kanade added the comment: Thanks Mark, for the explanation. I had no idea about how the floating point values are represented as binary fractions in the computer hardware. It was a very informative document. Thanks again! -- nosy: -serhiy.storchaka

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

2022-01-19 Thread Darshan Kanade
Darshan Kanade added the comment: The issue is that pi = k*math.cos(math.radians((90 - 180/k))) is giving wrong answer(289.384326...) for larger values of k, say k=2**62, but for smaller values say, k=100 it is giving correct answer(3.14) pi = k*math.sin(math.radians(180/k)) on the

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

2022-01-19 Thread Darshan Kanade
Change by Darshan Kanade : -- resolution: not a bug -> ___ Python tracker <https://bugs.python.org/issue46444> ___ ___ Python-bugs-list mailing list Un

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

2022-01-19 Thread Darshan Kanade
Change by Darshan Kanade : -- status: closed -> open ___ Python tracker <https://bugs.python.org/issue46444> ___ ___ Python-bugs-list mailing list Unsubscrib

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

2022-01-19 Thread Darshan Kanade
Darshan Kanade added the comment: In the program, I did convert degrees to radians So, this was what I used- 1)pi = k*math.cos(math.radians((90 - 180/k))) 2)pi = k*math.sin(math.radians(180/k)) where k=2**62 -- ___ Python tracker <ht

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

2022-01-19 Thread Darshan Kanade
New submission from Darshan Kanade : I was solving this problem to find the approximate value of pi using the Archimedes method using two different logics - 1) The first one used the formula pi = k*cos(90-180/k) but when I gave very large input, say k=2**62 sides of polygon, then it gives