GNU MPFR version 3.1.5 (released on 27 September 2016)

[download] [documentation] [bugs] [changes] [platforms] [timings of 3.1.2]

The canard à l'orange release, patch level 5.

MPFR 3.1.5 requires GMP 4.1.0 or higher (GMP 4.2.3 or higher is recommended).

Note: the bug-fix release MPFR 3.1.6 is available. Please upgrade!

Warning! Due to the fact that TLS support is now detected automatically, the MPFR build can be incorrect on some platforms (compiler or system bug). Indeed, the TLS implementation of some compilers/platforms is buggy, and MPFR cannot detect every problem at configure time. Please run make check to see if your build is affected. If you get failures, you should try the --disable-thread-safe configure option to disable TLS and see if this solves these failures. But you should not use an MPFR library with TLS disabled in a multithreaded program (unless you know what you are doing).


The MPFR 3.1.5 source can be downloaded in the following archive formats:

Each tarball is signed by Vincent Lefèvre. This can be verified using the DSA key ID 980C197698C3739D; this key can be retrieved with:

gpg --recv-keys 980C197698C3739D

or by downloading it from The key fingerprint is:

07F3 DBBE CC1A 3960 5078  094D 980C 1976 98C3 739D

The signatures can be verified with:

gpg --verify file.asc

You should check that the key fingerprint matches.

MPFR is also available via third-party packages and ports.



The bugs listed below have been fixed (latest update: 2017-08-01). The patches are distributed under the same license as this version of MPFR, that is, the GNU Lesser General Public License (GNU Lesser GPL), version 3 or later.

The following instructions are for Linux and may be similar for other operating systems. You can apply the patches in several ways:

With the first two ways, the PATCHES file is modified, so that one can know what patches have been applied, using the mpfr_get_patches function. Moreover a suffix is added to the version string, but note that for practical reasons, not all the files where the version appears are patched; thus one can also track applied patches with the MPFR_VERSION_STRING macro (header) and the mpfr_get_version function (library). However, if some patches are not applied or if patches are applied in a different order, then the patch command will fail to update some chunks, so that the suffix is not always reliable for patches.

Note: These patches are in unified diff format and some vendors' patch commands cannot deal with them; in this case, please use GNU patch (it may already be installed on your system, e.g. as /usr/local/bin/patch or gpatch).

Fixed bugs, with patches:

  1. The formatted output functions (mpfr_*printf) yield an undefined behavior or assertion failure when a precision less than −1 is given as an argument for the f or F conversion specifier (the given precision should have been ignored). This bug is fixed by the vasprintf patch, which also provides test cases.
    Corresponding changeset in the 3.1 branch: ca956bee (r11043).
  2. The function mpfr_strtofr can return an incorrect ternary value in the round-to-nearest mode (MPFR_RNDN). As a consequence, the value can also be incorrect if the current exponent range is not the maximum one (since the maximum exponent range is used internally and the ternary value is used to resolve double rounding when reducing the exponent range to the current one); this can happen only if the value is a midpoint between 0 and the minimum positive number or the opposite. This bug is fixed by the strtofr patch, which also provides a test case.
    Corresponding changeset in the 3.1 branch: f9159c62 (r11069).
  3. With GCC 7 and later, the build of MPFR fails when the -Wall -Werror options are both used, due to the new -Wint-in-bool-context option enabled by -Wall. This is not a bug in MPFR, but this failure prevents one from using such options to detect potential bugs and it affects the usual tests done before a release, the publication of the following patches, etc. It is due to the fact that the ternary value may also be regarded as a Boolean value signaling inexactness. This failure is avoided by the ret-macro patch.
    Corresponding changeset in the 3.1 branch: c7e84fc5 (r11536).
  4. With GCC 7 and later, the build of MPFR may fail with some combination of options due to GCC bug 79257. This bug is avoided by the tests-buffer-size patch.
    Corresponding changeset in the 3.1 branch: f18eab92 (r11537).
  5. The formatted output functions (mpfr_*printf) have issues in overflow checking (vasprintf.c, function partition_number) for the return value: These issues are fixed by the vasprintf-overflow-check patch.
    Corresponding changesets in the 3.1 branch: 01cd75f0 (r11538), be3a8e4e (r11541).
  6. In case of overflow for the return value of the formatted output functions (mpfr_*printf), errno is no longer set to EOVERFLOW when supported. This bug is fixed by the printf-errno patch.
    Corresponding changeset in the 3.1 branch: 43bd8574 (r11539).
  7. In the tsprintf test, the setlocale standard function is used incorrectly. This bug is fixed by the tsprintf-setlocale patch.
    Corresponding changeset in the 3.1 branch: 0f999001 (r11540).
  8. Some of the mpf2mpfr.h macros dealing with signed integers are incorrect. This bug is fixed by the mpf-compat-signed patch, which also provides non-regression tests (at the same time, some macros needed to be fixed for C++ compatibility).
    Corresponding changesets in the 3.1 branch: 8ebad79e (r11579) (the fix and non-regression tests), 6466fdff (r11580) (fix of macros for C++ compatibility, needed by the previous changeset).
  9. On platforms with a 32-bit unsigned long type (32-bit ABI or Microsoft Windows), computations in sin_cos.c suffer from overflows in high precisions (more than about 1,000,000 bits). In practice, this introduces an error of up to 2−1019574 approximately, so that the trigonometric functions (mpfr_sin, mpfr_cos, mpfr_sin_cos, mpfr_tan) and functions that call them can be very inaccurate (limiting the overall accuracy to about one million bits for these functions on such platforms). This bug is fixed by the sincos-overflow patch (no test cases are provided due to the high precisions needed to reproduce the bug, but the behavior can be tested with this small C program sin-tst.c, for instance with the argument 1.0).
    Corresponding changeset in the 3.1 branch: 7a2cc6eb (r11591).
    This bug was originally observed in Julia with BigFloat: bug report, previous discussion.
  10. Patch 8 (mpf-compat-signed patch) breaks linking for Microsoft Windows with DLL as a wrong header is included, yielding incorrect symbol definitions on this platform. This is fixed by the mpf-compat-header patch (to be applied on top of patch 8).
    Corresponding changeset in the 3.1 branch: b0a59295 (r11606).

Moreover, mpfr_urandom has several issues:

Some cleanup concerning thread-safe DLL on Windows has also been added, in particular to avoid compiler warnings.
Corresponding changeset in the 3.1 branch: 77ffa7c0 (r10917).

Other bugs: See the tracker and the BUGS file.

Changes from version 3.1.4 to version 3.1.5

Platforms Known to Support MPFR

MPFR 3.1.5 has been successfully compiled and checked on the following platforms:

Back to the MPFR page.