A C++ High Performance Arbitrary Precision Arithmetic Package

Apfloat is a high performance arbitrary precision package. That means you can do calculations involving millions of digits with it. It uses Number Theoretic Transforms. It's simple to use. It's fast. It's freeware.

A Java version is also available.

Apfloat could be compiled in general with most C++ compilers, however gcc is recommended. It has assembler optimizations for x86, Alpha and MIPS processors.

A sample program for calculating pi is included in the package. Calculating one million digits of pi takes less than half a minute with an Athlon XP computer. This makes it one of the fastest programs for calculating pi (faster than the Japanese super_pi program).

Compiled executables for calculating pi are available for download. The fastest versions of the program can calculate up to 226 million decimal digits of pi. A machine with at least 256 MB of RAM would be needed for such a calculation. A version, which can calculate up to 1.9 billion digits (if you have at least two gigabytes of memory) is also provided, but it is somewhat slower.

Zipped executableProcessorOperating systemMaximum number of digits
aptestg5.zipPentiumMicrosoft Windows (GUI)226 million
aptestc5.zipPentiumMicrosoft Windows (console)226 million
aptestc6.zipPentiumMicrosoft Windows (console)1.9 billion (slower!)
aptestm.zipPentium MultiprocessorMicrosoft Windows226 million
aptestm6.zipPentium MultiprocessorMicrosoft Windows1.9 billion (slower!)
aptest25.zipPentiumMS-DOS (requires DPMI)226 million
aptest26.zipPentiumMS-DOS (requires DPMI)1.9 billion (slower!)
aptest24.zip486MS-DOS (requires DPMI)226 million
aptest5.zipPentiumMS-DOS226 million
aptest4.zip486MS-DOS226 million
aptestlx.zipAthlon 64Linux x86-6461 billion (faster!)
aptestl5.zipPentiumLinux226 million
aptestl6.zipPentiumLinux1.9 billion (slower!)
aptestl4.zip486Linux226 million
aptestlm.zipPentium MultiprocessorLinux226 million
aptestll.zipPentium MultiprocessorLinux1.9 billion (slower!)

Compiled executables for printing Mersenne numbers and associated perfect numbers are also available for download:

Zipped executableProcessorOperating system
mprintc5.zipPentiumMicrosoft Windows

All corrections, comments and bug reports should be sent to the author.

Last updated: February 28th, 2005

Download the package here:

Newest version 2.41

If you have problems, you can try the older versions: 2.40, 2.35, 2.34, 2.33, 2.32, 2.31, 2.30, 2.21, 2.20, 2.10, 2.00, 1.51, 1.50, 1.40, 1.33, 1.32, 1.31, 1.30, 1.20, 1.10 or 1.02.

The apfloat Frequently Asked Questions (FAQ). Actually, they are not very frequently asked. I don't get a lot of questions from apfloat users.

If you have some other compiler than gcc, djgpp, Borland C++ or Microsoft Visual C++, you may want to look at instructions on creating your own makefile.

You might also want to try other freeware arbitrary precision arithmetic packages, like the hfloat package by Jörg Arndt, or the CLN package by Bruno Haible, which seems to be superior.

The apfloat version history.

People who have contributed to apfloat.

EU GDPR note: This website does not collect any personal data. The hosting provider, Telia Inmics-Nebula, collects some personal data such as IP address, as required by law.