[Cfp-interest 3303] ERANGE question

Paul Zimmermann Paul.Zimmermann at inria.fr
Wed Oct 9 00:30:10 PDT 2024


       Hi,

I have a question about ERANGE.

This question comes from whether x^y should set errno to ERANGE
for x=0x1.57fffffffffffp-1005 and y=-0x1.04f352c2db70ep+0
(in binary64 and rounding to nearest).

We have DBL_MAX < x^y < 2^1024*(1-2^-54), thus with unbounded
exponent, x^y rounds to DBL_MAX.

N3301 says "a range error occurs if and only if the result overflows or
underflows, as defined below".

And "A floating result overflows if a finite result value with ordinary
accuracy265) would have magnitude (absolute value) too large for the
representation with full precision in the specified type."

It is not clear to me if this is meant before or after rounding (with
unbounded exponent).

Should errno be set to ERANGE, even if x^y rounds to DBL_MAX?

Paul


More information about the Cfp-interest mailing list