Miscellaneous > Programming & Networking
First post!
voidmain:
Actually it's really easy to do in C (or any language for that matter) and it doesn't take a long to do it. You can figure it in an appropriately structured loop and output each digit as you figure it. The program doesn't actually keep the entire resulting number in memory. In fact you can go farther than 10,000 decimal places, will just take some time.
voidmain:
Well, here is an example in C:
http://mathforum.org/library/drmath/view/54343.html
On my Laptop with a PII 350Mhz it took just under 20 seconds to calculate pi to 10,000 decimal places without any code optimizations. On my Athalon 1600 it took just over 5 seconds to get 10,000 places with no optimizations.
If I compile the source with the "-O3" flag I see a *drastic* improvement. 1.8 seconds on the Athalon and 7.5 seconds on the PII.
You can time it by using the "time" command:
time ./a.out 10000
Also it should be noted that this program is only accurate up to a certain number of digits (not sure how many but I think it is under 1000 digits). Anyone have a really accurate method to calculate any number of digits? There must be a way since they have calculated many millions of digits.
[ July 21, 2002: Message edited by: VoidMain ]
jtpenrod:
quote:Ok, how do I calculate pi to 10,000 decimal places in C++?
--- End quote ---
See This Site for a C program to get the job done. There is also a Fortran program there as well. The only caviate is that the results can be determined in hex only. The algorithm doesn't work for decimal numbers.
_________________________________________
Live Free or Die: Linux
If software can be free, why can't dolphins?
[ July 21, 2002: Message edited by: jtpenrod ]
[ July 21, 2002: Message edited by: jtpenrod ]
choasmaster:
to caclutlate pi to millions of decimals places, well, the solarise admin down the street could probably tell me howto make a space shuttle, a railgun, give me 5 or 6 REAL movies of monica and clinton, letalone a program to calculate pi to a few billion decimal places, then agian, if did any of these, id probably be a test subject at area51
/*btw, if youve not figured out that he works at nsa and this is a joke, shame on you*/
Navigation
[0] Message Index
[*] Previous page
Go to full version