[Cfp-interest 3304] Re: ERANGE question

Vincent Lefevre vincent at vinc17.net
Wed Oct 9 05:45:37 PDT 2024


On 2024-10-09 09:30:10 +0200, Paul Zimmermann wrote:
>        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".

That's strange. AFAIK, underflows should not be range errors.

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

"the representation with full precision in the specified type" implies
that the result is rounded. Otherwise I don't see how this can be
interpreted.

But I'm wondering why the word "full" is used. Ditto in 6.4.5.3p7
about floating literals of decimal floating type. Is this because
some representations are not normalized, thus are regarded as
having less precision?

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

In rounding to nearest, I would say no.

But for the directed rounding modes, the definition seems wrong.
One should use the IEEE 754 definition.

-- 
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 Cfp-interest mailing list