Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
math.pi
#11
(Jan-08-2018, 09:44 AM)Gribouillis Wrote:
(Jan-08-2018, 05:08 AM)casevh Wrote: Unfortunately, your fraction only provides 53 bits of accuracy, not the 64 bits required by long double.
This computation is not correct, because when you write a=gmpy2.mpfr(8552228672519733982877442985294966266405.0), the python interpreter converts the number to float, which loses precision. You need to use some string "8552228672519733982877442985294966266405.0".

The following code using the bigfloat library confirms Skaperen's values

>>> from bigfloat import *
>>> with precision(133):
...  print(const_pi().as_integer_ratio())
... 
(8552228672519733982877442985294966266405, 2722258935367507707706996859454145691648)
You are correct. I had meant to keep the values as integers.

@Skaperen, please accept my apologies.

casevh
Reply


Messages In This Thread
math.pi - by Skaperen - Jan-08-2018, 03:17 AM
RE: math.pi - by casevh - Jan-08-2018, 04:23 AM
RE: math.pi - by Skaperen - Jan-08-2018, 04:35 AM
RE: math.pi - by casevh - Jan-08-2018, 05:08 AM
RE: math.pi - by casevh - Jan-08-2018, 06:17 AM
RE: math.pi - by wavic - Jan-08-2018, 07:06 AM
RE: math.pi - by casevh - Jan-08-2018, 07:31 AM
RE: math.pi - by Gribouillis - Jan-08-2018, 09:44 AM
RE: math.pi - by casevh - Jan-08-2018, 01:22 PM
RE: math.pi - by wavic - Jan-08-2018, 10:22 AM
RE: math.pi - by Gribouillis - Jan-08-2018, 11:29 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020