[cfp-interest 3400] Re: nexttoward

Fred J. Tydeman tydeman at tybor.com
Mon Mar 3 11:13:58 PST 2025


On Mon, 03 Mar 2025 18:57:29 +0100 Paul Zimmermann wrote:
>
>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



---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of INCITS/C (ANSI "C")
Sample C17+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the cfp-interest mailing list