GNU MPFR version 3.1.4 (released on 6 March 2016)

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

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

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

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

Warning! Due to the fact that Thread-Local Storage (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.4 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 98C3739D; this key can be retrieved with:

gpg --recv-keys 98C3739D

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: 2016-09-12). 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. Compilation can fail under Microsoft Windows if the __unix__ macro is defined. This problem occurs in particular with the 32-bit Cygwin. This is due to consistency checks added for MPFR 3.1.4 (useful mainly for the developers). This is fixed by the unix-check patch, which just removes these checks (this is OK for the 3.1 branch, which should now be stable enough, and in the trunk, the status of some macros are output by tversion to replace these checks).
    Corresponding changeset in the 3.1 branch: 10264.
  2. Functions mpfr_add_ui and mpfr_sub_ui do not set all the expected flags; in practice, this concerns only the NaN flag. This bug is fixed by the add-sub-ui-flags patch, which also provides test cases.
    Corresponding changeset in the 3.1 branch: 10304.
  3. The code that subtracts two numbers of the same sign, called by mpfr_add on numbers of different signs and by mpfr_sub on numbers of the same sign, i.e. which does a = b − c with |b| > |c|, is incorrect in the following case: Here the function returns an infinity with the overflow flag set instead of ± the maximum number without generating an overflow. The cause is that an overflow is generated too early, in an intermediate rounding, before one has the chance to correct the intermediate result for midpoint cases. This bug is fixed by the sub1-overflow patch, which also provides test cases.
    Corresponding changeset in the 3.1 branch: 10384.
  4. The build of some tests fails with C++11 compilers (e.g. g++ with the -std=c++11 option, and just g++ as of GCC 6) due to a change in the parsing behavior in C++11 (for the support of user-defined literals). This incompatibility issue is fixed by the c++11-compat patch.
    Corresponding changesets in the 3.1 branch: 10720 (the only one which actually fixes the incompatibility issue), 10722, 10728.
  5. The mpfr_can_round_raw internal rounding-test function, used by the mpfr_can_round public function, is still buggy: there had already been a patch for MPFR 3.1.3, applied in MPFR 3.1.4, which fixed some particular cases, but new bugs have recently been found. This function still has false positives in some cases, i.e. it can return true (meaning that correct rounding is possible) instead of false (meaning that correct rounding is not guaranteed). It also has false negatives, some of which can yield infinite Ziv loops in user code in practice. Some MPFR math functions might be affected by false positives, but most of them use other internal methods instead of this function. This bug is fixed by the can_round2 patch, which also provides test cases (in particular a comprehensive test against a naive implementation).
    Corresponding changeset in the 3.1 branch: 10792.
    An example of false positive is given by the following code.
    #include <stdio.h>
    #include <mpfr.h>
    int main (void)
      mpfr_t x;
      int r;
      mpfr_init2 (x, 3);
      mpfr_set_ui (x, 5, MPFR_RNDN);
      r = mpfr_can_round (x, 4, MPFR_RNDN, MPFR_RNDN, 3);
      printf ("%d\n", r);
      mpfr_clear (x);
      return 0;
    Here, the number 5 is an approximation to an unknown number in the interval [5 − 1/2, 5 + 1/2]. In round-to-nearest (with the even rounding rule) and the target precision 3, the number 5 − 1/2 rounds to 4, while the number 5 + 1/2 rounds to 6. Thus the program should output 0, but with MPFR 3.1.4, one gets 1.
  6. On platforms with little-endian x86 extended precision, the mpfr_get_ld function does not round correctly in the subnormal range due to an incorrect value of the minimum exponent. This is fixed by the get_ld patch.
    Corresponding changesets in the 3.1 branch: 10815 (main one), 10852, 10853, 10855 (main fix of the test), 10856, 10857.
    Note: This bug has always been present since the introduction of the code for x86 extended precision in r3226 (before, this was not supported). The maximum exponent was incorrect too, but had been fixed in r6101 (r6204 for the 2.4 branch and MPFR 2.4.2). Note also that for these conversion functions with native floating-point types, correct rounding is not guaranteed in general, but we try to do our best when the native format can be recognized.

Other bugs: See the tracker and the BUGS file.

Changes from version 3.1.3 to version 3.1.4

Platforms Known to Support MPFR

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

Back to the MPFR page.