0
PI to more than 15 digits
From math import pi Print (pi) Python returns PI number to only 15 digits after decimal point. How can I print it to more digits?
6 Answers
+ 7
# https://stackoverflow.com/a/13316984
from mpmath import mp
print(mp.pi)
mp.dps = 20
print(mp.pi)
# Or write your own algorithm...
+ 1
You can check this thread too. Many creative solutions in Python and other languages too.
https://www.sololearn.com/post/237769/?ref=app
0
Lisa great, thanks a lot šš
0
I can only Tell you how I did it(Not Python). I made it so that I parsed Pi to int and checked if the Last value had the number and else of that wasn't the Case I multipled it by 10 and that in a Loop.
What I want to say you get later PI values by multiplying it with 10, 100...
0
Felix Alcor That only works if you can take for granted that pi is stored with more digits that are displayed. Suppose pi was stored as 3.14. Moving the decimal point doesn't increase precision of pi.
0
Lisa Yep I told it so because He seems to use PI from a libary for Math. I guess the same as Math.Pi(C#)