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


Forum Jump:

User Panel Messages

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