The Computer Language
23.03 Benchmarks Game

pidigits description


MathWorld: Pi Digits.

HN discussion


Some language implementations have arbitrary precision arithmetic built-in; some provide an arbitrary precision arithmetic library; some use a third-party library (GMP); some provide built-in arbitrary precision arithmetic by wrapping a third-party library.

The work

The work is to use aribitrary precision arithmetic and the same step-by-step single-threaded algorithm to generate digits of Pi. Do both extract(3) and extract(4). Don't optimize away the work.

How to implement

We ask that contributed programs not only give the correct result, but also use the sequential algorithm to calculate that result.

Each program should:

diff program output N = 30 with this output file to check your program output has the correct format, before you contribute your program.

Use a larger command line argument (10000) to check program performance.

Adapt the step-by-step algorithm given on pages 4,6 & 7 of [pdf 156KB] Unbounded Spigot Algorithms for the Digits of Pi. (Not the deliberately obscure version given on page 2. Not the Rabinowitz-Wagon algorithm.)