Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Mr.Midnight, Jun 18, 2016.
Ello I am trying to make a Pi calculator for my server, how can I implement such an algorithm?
"First 1000 digits of pi"
Such small ambitions
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
Doesn't double data type only limit to 15 decimal places?
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
Just use stuff to grab the text in this https://www.angio.net/pi/digits/1000.txt
EDIT: Or if your ambitions improve, there's always this https://www.angio.net/pi/digits/pi1000000.txt
I thought it would be a fun addition for my players to be able to calculate pi.
We can do better
Sorry I am not the best at math either :C
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
what happens if you put a never ending decimal division in java? does it crash?
Dunn... Dunnnnn... Dunnnnna D:
I doubt that. Probably would throw an exception though.
Edit: You could do it with something like the Nilakantha series.
It'd throw an exception. Java doesn't allow developers to do stupid things ;(
So making a long division algorithm to get the first 1000 digits seems the best way.
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: