-
Pi Calculator
I'm writing a program that calculates Pi in C and i'm using a double data structure to store the final result. Double only gives me a certain amount of digits after the decimal point. My question is, what kind of data structure or what method could I use if I potentially wanted to have it calculate 100 digits or more after the decimal point?
-
Re: Pi Calculator
You need a package for arbitrary-precision arithmetics,
http://en.wikipedia.org/wiki/Arbitra...ion_arithmetic
-
Re: Pi Calculator
If your need is to simply determine the digits in PI and not use this extended precision number in any calculations, then all you need is an algorithm. Sorry that I can't suggest one, but a Google search should turn up several sources - or maybe someone here could recommend one.
To clarify: the extended precision digits could be stored in an array of integers or as ASCII characters in a string. Obviously, if stored this way you would not be able to use the value in any calculations.
-
Re: Pi Calculator
Thx for the inputs. I'll look into arbitrary precision arithmetic.
-
Re: Pi Calculator
gmp is a common and easy to use one.