MPFR and the IEEE 754 Standard (GNU MPFR 4.2.1)
Description: How to install and use GNU MPFR, a library for reliable multiple precision floating-point arithmetic, version 4.2.1.

## 7 MPFR and the IEEE 754 Standard

This section describes differences between MPFR and the IEEE 754 standard, and behaviors that are not specified yet in IEEE 754.

The MPFR numbers do not include subnormals. The reason is that subnormals are less useful than in IEEE 754 as the default exponent range in MPFR is large and they would have made the implementation more complex. However, subnormals can be emulated using `mpfr_subnormalize`.

MPFR has a single NaN. The behavior is similar either to a signaling NaN or to a quiet NaN, depending on the context. For any function returning a NaN (either produced or propagated), the NaN flag is set, while in IEEE 754, some operations are quiet (even on a signaling NaN).

The `mpfr_rec_sqrt` function differs from IEEE 754 on −0, where it gives +Inf (like for +0), following the usual limit rules, instead of −Inf.

The `mpfr_root` function predates IEEE 754-2008, where rootn was introduced, and behaves differently from the IEEE 754 rootn operation. It is deprecated and `mpfr_rootn_ui` should be used instead.

Operations with an unsigned zero: For functions taking an argument of integer or rational type, a zero of such a type is unsigned unlike the floating-point zero (this includes the zero of type `unsigned long`, which is a mathematical, exact zero, as opposed to a floating-point zero, which may come from an underflow and whose sign would correspond to the sign of the real non-zero value). Unless documented otherwise, this zero is regarded as +0, as if it were first converted to a MPFR number with `mpfr_set_ui` or `mpfr_set_si` (thus the result may not agree with the usual limit rules applied to a mathematical zero). This is not the case of addition and subtraction (`mpfr_add_ui`, etc.), but for these functions, only the sign of a zero result would be affected, with +0 and −0 considered equal. Such operations are currently out of the scope of the IEEE 754 standard, and at the time of specification in MPFR, the Floating-Point Working Group in charge of the revision of IEEE 754 did not want to discuss issues with non-floating-point types in general.

Note also that some obvious differences may come from the fact that in MPFR, each variable has its own precision. For instance, a subtraction of two numbers of the same sign may yield an overflow; idem for a call to `mpfr_set`, `mpfr_neg` or `mpfr_abs`, if the destination variable has a smaller precision.