# Calculating the first 1000 digits of pi

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

1. ### Mr.Midnight

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

Math.PI

• Funny x 2
• Winner x 1
3. ### Mr.Midnight

"First 1000 digits of pi"

4. ### Redrield

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. ### Choco Moderator

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

BigDecimal?

8. ### Choco Moderator

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
10. ### Mr.Midnight

I thought it would be a fun addition for my players to be able to calculate pi.

13. ### Mr.Midnight

Sorry I am not the best at math either :C

14. ### 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

15. ### lookcook

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

• Creative x 1
16. ### Mr.Midnight

Dunn... Dunnnnn... Dunnnnna D:

17. ### BorisTheTerrible

I doubt that. Probably would throw an exception though.

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

18. ### bob7l

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

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

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

20. ### 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)