[Cfp-interest 3306] Re: ERANGE question
Vincent Lefevre
vincent at vinc17.net
Wed Oct 9 06:08:11 PDT 2024
On 2024-10-09 14:45:37 +0200, Vincent Lefevre wrote:
> 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.
Well, that was the (vague) definition in C99:
Similarly, a /range error/ occurs if the mathematical result of the
function cannot be represented in an object of the specified type,
due to extreme magnitude.
But it has evolved over the years, starting in C17.
--
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