I saw here how to find the sqrt(2) up to 100 digits in python:
import decimal
number = decimal.Decimal(2)
precision = decimal.Context(prec = 100)
print (number.sqrt(precision))
I tested and worked fine. When I try to use this code to pi, the print doesn't work. I tried
print (number.(precision))
, print (number(precision))
, etc. How the last line should be?
import decimal
number = decimal.Decimal(math.pi)
precision = decimal.Context(prec = 100)
print (???)
I'm using netbeans. I can, however, print the sqrt(pi).
EDIT: Thanks, guys!
Python returns: 3.141592653589793-1-159979634685441851615905761718750
Wolfram returns 3.141592653589793-2-384626433832795028841971693993751
Only after 14 digits the answer's diverges. Is math.pi from python reliable?
Strange enough, but the sqrt(2) up to 1000 digits in python and wolfram gives the same answer.