Python Forum

Full Version: math.pi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(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
Pages: 1 2