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

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


On 2022-09-16 16:34:58 -0400, Eric Li wrote:
> Thanks to https://stackoverflow.com/a/73740744, looks like the cause of
> the bug it that GMP triggered a signed overflow in the following code
> (from https://gmplib.org/repo/gmp/file/feb796a7f683/mpf/set_str.c#l315)
[...]

I've given an answer:

  https://stackoverflow.com/a/73906883/3782797

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
behavior.

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


More information about the gmp-bugs mailing list