MPFR++ is a C++ tool that creates a link between MPFR and C++ for developers who are interested in developing programs that utilize high-precision floating-point arithmetic.
One of the main features of MPFR++ is the MpfrClass class. This class encapsulates the MPFR type, providing several constructors that can create objects from basic numerical types, GMP types (mpz, mpq), the mpfr type, and from a string.
MPFR++ also includes an assignment and copy feature. The assignment operator (=) is a logical copy, while the copy function performs a physical copy. Functions that can modify or consult the rounding mode or computing precision are also included. These functions include GetDefaultRndMode, SetDefaultRndMode, GetDefaultPrecision, GetPrecision, SetDefaultPrecision, and SetPrecision.
MPFR++ also provides several constants, including Pi, Log2, and Euler. Arithmetic operations can be performed where one of the operands can be an object of type MpfrClass, a numerical object with a basic or GMP type. Functions such as fma for fused multiply and accumulate, abs, sqrt, cbrt, pow, hypot, and factorial are also included.
Several correctly rounded mathematical functions are available, such as random, agm, exp, exp2, expm1, log, log2, log10, log1p, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, gamma, erf, and zeta.
Comparison operators such as ==, !=, =, min, and max are also included. In addition, Input-Output functions can be used. Functions related to the IEEE-754 standard for floating-point arithmetic are also available, such as rounding according to the four rounding modes prescribed in the standard, nextabove, nextbelow, and nexttoward.
MPFR++ features a reference counter that reduces the physical copies of objects. Each object contains a reference counter that displays the number of objects that are logically different but share the same physical value. Objects with a reference counter equal to 1 can be modified physically. However, if the reference counter is greater than 1, duplicating and modifying the object is the only option to avoid modifying the value of other objects that reference the same value.
New versions of the software are periodically released. The latest version is compatible with MPFR 2.2.0 and gcc 4.x.x.