Discuss Scratch
- mumu245
-
1000+ posts
How to calculate Pi?
(#11)Scratch is not precise enough.
There's a pretty cool infinite sum that can be used to calculate pi:
(I swear there's an image, cubeupload's just down)
However, it's pretty slow. You have to sum like the first thousand terms of the terms to get like the first four places of pi.
There's a faster one called the Machin formula, but it requires a little more math:
(There's also an image here)
You can find the arctangent block from the operators section:([atan v] of ())
* * *
Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.
- PhiPhenomenon
-
500+ posts
How to calculate Pi?
If the OP wanted to, they could use the arbitrary-precision arithmetic described in Super Pi Calc by DadOfMrLog. To avoid loss of precision from Scratch decimals, it uses lists to keep track of individual terms. Then it manually sums them together instead of using the addition operator.(#11)Scratch is not precise enough.
There's a pretty cool infinite sum that can be used to calculate pi:
(I swear there's an image, cubeupload's just down)
However, it's pretty slow. You have to sum like the first thousand terms of the terms to get like the first four places of pi.
There's a faster one called the Machin formula, but it requires a little more math:
(There's also an image here)
You can find the arctangent block from the operators section:([atan v] of ())
* * *
Decimals in Scratch aren't infinitely precise. The computer uses 58 bits, which equates to about 10 digits.