Wednesday, April 4, 2012

Further adventures in sequence counting

So I grabbed a file with the 1st billion digits of pi to play with that as well. Using standard c types I ran into overflow issues when I got to around the 48 millionth digit. Luckily there is the GNU MP library. So converting things to using the mpz_t type I was able to scan the billion digits and get an answer. The call overhead for using mpz_t and its related functions only added 2 seconds of runtime.

The answer for 1000000000 digits is:

snits@cantor:~/proj/c/pi=>time ./nseqpi pi-1000000000.txt
sequence 1, 2, 3: 1000000000 166644616079693012548675 1323986657

real 0m18.796s
user 0m18.191s
sys 0m0.186s

No comments:

Post a Comment