Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: badkarma on 20 July 2002, 04:59

Title: First post!
Post by: badkarma on 20 July 2002, 04:59
yay  :D
Title: First post!
Post by: choasmaster on 20 July 2002, 05:06
what the hell is this, slashdot???
Title: First post!
Post by: badkarma on 20 July 2002, 06:33
no ... but I was bored .. and couldn't think of anything usefull to say ....

anyways ... any c++/ Qt programming questions can be fired at my direction  :D
Title: First post!
Post by: voidmain on 20 July 2002, 07:42
Ok, how do I calculate pi to 10,000 decimal places in C++?
Title: First post!
Post by: choasmaster on 20 July 2002, 13:19
your defiantly gonna need to use long long. im guessing that c++ would be terible langauge to do that in, im guessing that fortran would be a better idea
Title: First post!
Post by: voidmain on 20 July 2002, 19:35
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.
Title: First post!
Post by: voidmain on 21 July 2002, 08:48
Well, here is an example in C:

http://mathforum.org/library/drmath/view/54343.html (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 ]

Title: First post!
Post by: jtpenrod on 21 July 2002, 11:37
quote:
Ok, how do I calculate pi to 10,000 decimal places in C++?
See This Site (http://www.mathsoft.com/asolve/plouffe/pi_c.txt) 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
(http://www.otakupc.com/etsig/dolphin.gif)
If software can be free, why can't dolphins?

[ July 21, 2002: Message edited by: jtpenrod ]

[ July 21, 2002: Message edited by: jtpenrod ]

Title: First post!
Post by: choasmaster on 21 July 2002, 13:22
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*/