[cfp-interest 3467] Re: nexttoward

Damian McGuckin damianm at esi.com.au
Wed May 21 21:02:41 PDT 2025


On Wed, 14 May 2025, Jim Thomas wrote:

> If the library implementation does not claim conformance to Annex F it can
> choose to not report an underflow range error, even if math_errhandling &
> MATH_ERREXCEPT is nonzero. This means the (non-Annex F) implementation can
> choose to not raise the floating-point exceptions in these cases.
> However, Annex F conformance requires the floating-point exceptions in these
> cases. F.10.9.3 says
> 
> ? nextafter(x, y) raises the "underflow" and "inexact" floating-point
> exceptions for the function value subnormal or zero and x ? y.
> 
> Annex F took this spec from IEEE 754-1985 and retains it as a legacy 
> feature though revisions of IEEE 754 do not include the nextafter 
> functions.

Ly,

As Jim noted, it is really whether you want Annex F compliance.  I would 
always want that option to be available (as a programmer).

If you are worried by the overhead of either setting ERANGE or raising the 
exceptions, at least one implementation has chosen to avoid setting ERANGE 
but to still identify the exceptional cases of whether an infinite result 
or a subnormal or zero result is returned. That way, they can still claim 
Annex F conformance but reduce their overhead. I am of the impression that 
the former has significantly more overhead that the latter. Then again, 
raising an exception still has some overhead which is obviously not the 
same as no overhead.

Regards - Damian


More information about the cfp-interest mailing list