NOTE
e_float-2021 preserves a legacy library. More modern work can be found in the wide-decimal project.
e_float-2021 is a C++ multiple-precision floating point library that
implements drop-in big float types that can be used essentially
like regular built-in floating-point types.
e_float-2021 is written as a classic source/header C++11 library,
and is compatible through C++11, 14, 17, 20, 23 and beyond.
e_float-2021 is a derived work from the original (legacy) e_float code and
paper.
This work is based on an earlier work:
C.M. Kormanyos, Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations,
in ACM TOMS (37) 4, February 2011
e_float-2021 implements multiple-precision floating-point
data types in modern C++11. Three versions are supported
in three individual build configurations. There is a native,
portable decimal float type called efx::e_float.
There are also wrapped versions
for GMP
and MPFR
called gmp::e_float and mpfr::e_float, respectively.
e_float-2021 is derived from the original work mentioned above.
The code has been updated to conform with
C++11, 14, 17, 20, 23 and beyond. It has been maintained and modernized,
and a dedicated effort has been made retain
compatibility with C++ language evolution.
Certain special function tests have been removed
from the larger scope of the original published work,
retaining just a core of the most essential key functions
and tests.
For the efx version (which is a decimal floating point implementation), a naive FFT brings the digit range up to a million decimal digits or more. This digit range was not available to the efx version at the time of the original e_float paper. The gmp and mpfr versions support high digit counts natively from their wrapped libraries.
An old manual can be found here. Posters exhibiting fascinating calculations performed with the original (legacy) e_float code can be found here and here.
- Open a bash shell in a terminal in the directory
libs/e_float/build. - The bash shell should be located directly in
libs/e_float/buildfor the paths to work out (be found by the upcoming build). - Identify the
Makefile. - Execute
makewith the command below (or similar with other supported options).
cd ./libs/e_float/build
make MP=efx TYP_TOOLSET=g++ TYP_STD=c++11 TYP_TEST=E_FLOAT_TEST_REAL_IMAG_TESTS rebuild- Identify the build directory.
- Execute a manually written command line such as the one below.
- File lists (
GCC_FilesPi.txtorGCC_FilesTest.txt) are included with the@-filename syntax of GCC. - The type of build is manually specified with either
-DE_FLOAT_TEST_PI_ALGOS_TESTSor-DE_FLOAT_TEST_PI_ALGOS_TESTS(in association with the appropriate one of the file lists given in the previous point.
The following command builds the pi algorithm tests for the efx backend.
cd ./libs/e_float/build
g++ -march=native -mtune=native -O3 -Wall -Wextra -Wno-cast-function-type -std=c++11 -DE_FLOAT_TYPE_EFX -DE_FLOAT_TEST_PI_ALGOS_TESTS -I../../../libs/e_float/src @GCC_FilesPi.txt ../src/e_float/efx/e_float_efx.cpp -o e_float.exeThe following command builds the real/imaginary e_float tests for the efx backend.
cd ./libs/e_float/build
g++ -march=native -mtune=native -O3 -Wall -Wextra -Wno-cast-function-type -std=c++11 -DE_FLOAT_TYPE_EFX -DE_FLOAT_TEST_REAL_IMAG_TESTS -I../../../libs/e_float/src @GCC_FilesTest.txt ../src/e_float/efx/e_float_efx.cpp -o e_float.exe- Identify the
e_floatsln-project file in the directory ./libs/e_float/build. - Rebuild any of the supported configurations such as
release-efx, as shown in the build image.
At the moment, two test suites are available in the project. These can be activated with preprocessor definitions.
E_FLOAT_TEST_REAL_IMAG_TESTSperforms low-digit (i.e., around 100-300 decimal digits) tests of algebraic operations, numeric limits, and real-valued and complex-valued elementary transcendental functions.E_FLOAT_TEST_PI_ALGOS_TESTSexercises four different variations of iterative, sub-quadratically converging million digit pi calculations.
These compiler switches can be manually set near the top of the file
e_float_base.h here,
or on the command line of the compiler call.
Continuous integration runs on push using GitHub Actions. Various compilers, operating systems, and C++ standards ranging from C++11, 14, 17, 20 are included in CI.
Boost bindings for Boost.Math and Boost.Multiprecision can be found in
the e_float.hpp header.
Examples of using boost bindings can be found in the test_boost project.
An extensive collection of iterative algorithms for calculating
pi can be found in pi_algos.cpp.
Included are algorithms having quadratic, cubic, quintic, nonic and hexadecimalic
convergence properties. These are used to exercise 1 million digit pi calculations.
The original e_float project influenced the fundamental
concept and creation of
Boost.Multiprecision.
After the publication of the e_float paper in
ACM TOMS (37) 4, February 2011,
the code was evaluated regarding how it
wrapped and implemented certain big number backends.
This idea for wrapping big number backends
was adopted for the partial early design of
cpp_dec_float
in Boost.Multiprecision. As Boost.Multiprecision progressed,
the original rudimentary frontend/backend concept
from e_float was redesigned and improved.
Boost.Multiprecision was subsequently expanded. Its functionality was extended and it evolved into today's header-only, template design having its own novel, flexible, robust frontend/backend concept.
e_float-2021 remains supported in order to provide historical
and legacy insight into the early origins of a work that influenced
Boost.Multiprecision.
The algorithms and implementation methods in e_float-2021 may also provide some level of guidance and practical advice on how to deal with big floating-point realizations within the context of modern C++.
The e_float project itself and e_float-2021 are, in fact, derived from an earlier
work named mp_cpp.
mp_cpp was created in the 1990s and its source code
has been preserved. At the time of its creation,
mp_cpp seemed subjectively to be quite cutting-edge
in its approach to dealing with big floating-point numbers
within the context of the C++ language.