[Cfp-interest 3100] Issue: frexp and double-double underflow

Hubert Tong hubert.reinterpretcast at gmail.com
Tue Apr 23 14:47:08 PDT 2024


frexp is not specified to have any failure conditions, but it necessarily
will fail to return the specified values for some double-double inputs.

The following program will fail on the second assertion due to underflow in
the less significant component of the double-double value.
#include <assert.h>
#include <math.h>
#include <float.h>
int main() {
  int exp;
  const long double oneplus = 1.L + DBL_TRUE_MIN;
  const long double frac = frexp(oneplus, &exp);
  assert(exp == 1);
  assert(frac * 2 == oneplus);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20240423/1cd4cd16/attachment.htm>


More information about the Cfp-interest mailing list