Publisher review:Pi.C - Calculate PI to 8,000 digits PI.C - Computes Pi to an arbitrary number of digits
Uses far arrays when/where required so may be compiled in any memory modelThe formula that most use (including the one in the Snippets) is the classic Machin formula, with the Gregory series.pi=16arctan(1/5)-4arctan(1/239) And use the traditional Gregory arctangent series to calculate the arctangents. That's the:arctan(x)=x-(x^3)/3 (x^5)/5-(x^7)/7..... With 1/5 and 1/239, it would be:arctan(x)=1/5-1/(3*5^3) 1/(5*5^5)-1/(7*5^7)...arctan(x)=1/239-1/(3*239^3) 1/(5*239^5)-1/(7*239^7)....Doing the multi-precision isn't too hard, since we don't really need to have a general purpose math package. We can hardwire it all.Due to the % operator, ms[i] < (temp * (239**2)) so temp < 3759 and i < 1879, it fails at the 1879th term which translates to 1879 * log10(239**2) == 8941th decimal.
In practice we get a few more digits, (2 -> 8943th)
Pi.C is a C/C++ script for Snippets scripts design by Bob Stout.
It runs on following operating system: Windows / Linux / BSD / Solaris.
Operating system:Windows / Linux / BSD / Solaris