문제

I am actually very new to C, but for a project, I'd like to be able to calculate the value of Pi from 1 million to at least 32 million decimal places. Basically, like what SuperPi/HyperPi does for benchmarking a CPU.

But obviously, the standard C library is incapable of this.

What library can I use, and what algorithm do I use for this task?

And precision too, anyone can cook up a rand() bloat and call it the "Ultimate value of Pi".

My compiler is GCC, so if possible, I'd like the library to be able to compile on it(I have the BigNum library).

도움이 되었습니까?

해결책

I'v used the quadratic algorithm from there with success. I'd suggest MPFR for the library part.

다른 팁

As for the algorithm, see http://en.wikipedia.org/wiki/Chudnovsky_algorithm. For a library to deal with bignums, check http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic#Libraries. Have fun.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top