# Calculating the first 1000 digits of pi

Discussion in 'Spigot Plugin Development' started by Mr.Midnight, Jun 18, 2016.

1. Ello I am trying to make a Pi calculator for my server, how can I implement such an algorithm?

2. Math.PI • Funny x 2
• Winner x 1
3. "First 1000 digits of pi"

4. Such small ambitions

• Agree x 2
• Funny x 1
5. ### lookcook

Maybe you could do a algorithum that manually does division, sort of like how you would do long division,

isnt pi like a circumference / diameter of a circle?

Than stop the algorithum if it goes 1000 times

6. Doesn't double data type only limit to 15 decimal places?

7. BigDecimal?

8. Yea I suppose so. Wait; what do you need 1,000 units of Pi for anyways? Rounding to 15 digits should suffice and get you a pretty spot on answer

• Agree x 1
• Funny x 3
• Useful x 1
9. I thought it would be a fun addition for my players to be able to calculate pi.

10. ### lookcook

11. Sorry I am not the best at math either :C

12. ### lookcook

Just make a algorithum that does long division steps 1000 times, get a circumference and diameter of a random circle. then put it in that algorithum m9,

isnt long division like:

check how much times a number can go into another, than you put it on top, than u multiply, than you subtract it from the numbers ur dealing with, than u take the remaining and move on or something xD

13. ### lookcook

what happens if you put a never ending decimal division in java? does it crash?

• Creative x 1
14. Dunn... Dunnnnn... Dunnnnna D:

15. ### BorisTheTerrible

I doubt that. Probably would throw an exception though.

Edit: You could do it with something like the Nilakantha series.

16. ### bob7l

It'd throw an exception. Java doesn't allow developers to do stupid things ;(

• Agree x 1
• Funny x 1
17. ### lookcook

So making a long division algorithm to get the first 1000 digits seems the best way.

18. ### BillyGalbreath

Pi is the circumference of a circle with 1 unit diameter.

Basically, if you have a wheel and it's 1 meter in diameter, the circumference would be Pi meters.

Thus, the equation for circumference is 2πr (2 * pi * radius) But to answer the original question... See this link:

https://cs.uwaterloo.ca/~alopez-o/math-faq/mathtext/node12.html

#20
Last edited: Jun 18, 2016
• Agree x 1