BBP Code Directory

David H. Bailey
Update: 2006-09-08


Here are some papers and computer programs that implement the BBP algorithm for computing digits of pi beginning at an arbitrary starting position.
  1. A short description of the BBP algorithm, with details regarding computer implementation: PDF.
  2. piqpr8.c: a C implementation using standard 64-bit floating-point arithmetic. On most systems using IEEE 64-bit floating-point arithmetic, this code works correctly for inputs up to approximately 1.18 x 10^7 (higher if 80-bit arithmetic can be employed). See note below. piqpr8.c
  3. piqpr8.f: a Fortran-90 implementation using standard 64-bit floating-point arithmetic. On systems using IEEE 64-bit floating-point arithmetic, this code works correctly for inputs up to approximately 1.18 x 10^7 (higher if 80-bit arithmetic can be employed). See note below. piqpr8.f
  4. piqpr16.f: A Fortran-90 implementation using 128-bit floating-point arithmetic (if available). The upper limit on the input position is not known for this program, but most likely it is at least 10^14, depending on the system used. See note below. piqpr16.f
With any of these programs, the result for position d can be easily checked by computing, in a second run, the result for position d-1 (or d+1). If the results perfectly overlap with an offset of 1, except possibly for a few trailing digits, then this is a strong indication that the code is working properly and that the results are valid.