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?

12th Jul 2022, 3:53 PM
MOJTABA MEHRI
MOJTABA MEHRI - avatar
6 ответов
+ 7
# https://stackoverflow.com/a/13316984 from mpmath import mp print(mp.pi) mp.dps = 20 print(mp.pi) # Or write your own algorithm...
12th Jul 2022, 4:18 PM
Lisa
Lisa - avatar
+ 1
You can check this thread too. Many creative solutions in Python and other languages too. https://www.sololearn.com/post/237769/?ref=app
12th Jul 2022, 6:58 PM
Tibor Santa
Tibor Santa - avatar
0
Lisa great, thanks a lot 🙏🙏
12th Jul 2022, 4:27 PM
MOJTABA MEHRI
MOJTABA MEHRI - avatar
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...
12th Jul 2022, 4:36 PM
Felix Alcor
Felix Alcor - avatar
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.
12th Jul 2022, 5:04 PM
Lisa
Lisa - avatar
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#)
12th Jul 2022, 5:26 PM
Felix Alcor
Felix Alcor - avatar