GMP does not detect float exponent overflow while reading floating point numbers

Vincent Lefevre vincent at
Fri Sep 30 14:29:01 CEST 2022

On 2022-09-16 16:34:58 -0400, Eric Li wrote:
> Thanks to, looks like the cause of
> the bug it that GMP triggered a signed overflow in the following code
> (from

I've given an answer:

This is not a bug. This is documented in the GMP manual:

  The 'mpf' functions and variables have no special notion of infinity
  or not-a-number, and applications must take care not to overflow the
  exponent or results will be unpredictable.

As Paul said, you should use GNU MPFR if you want well-defined

Vincent Lefèvre <vincent at> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-bugs mailing list