[cfp-interest 3401] Re: nexttoward

Paul Zimmermann Paul.Zimmermann at inria.fr
Tue Mar 4 00:12:36 PST 2025


       Hi Fred,

> >I have a question about nexttoward(). The Linux man page says:
> >
> >       double nexttoward(double x, long double y);
> >
> >...
> >
> >       If x is not equal to y, and the correct function result would be subnor-
> >       mal, zero, or underflow, a range error occurs, and  either  the  correct
> >       value (if it can be represented), or 0.0, is returned.
> >
> >For example nexttoward (0.0, 1.0) will set errno = ERANGE.
> >
> >I wonder why this is so, since for mathematical functions, underflow is not
> >raised (and thus errno is not set to ERANGE) when the result is exact.
> >And nexttoward always delivers an exact result.
> 
> IEEE-754-1985 "required" underflow for those cases.
> However, that is in an Appendix of Recommended Functions

but there is no underflow requirement in 754-2008 nor in 754-2019
(where the only related functions are nextUp and nextDown).

Paul


More information about the cfp-interest mailing list