[cfp-interest 3457] Re: nexttoward
Vincent Lefevre
vincent at vinc17.net
Wed May 14 08:58:17 PDT 2025
On 2025-05-14 11:29:14 -0400, LNT wrote:
> Sorry for a late reply / update about nexttoward / nextafter issue with
> underflow exceptions.
>
> On the latest draft of C2y, section 7.12.2.7 about underflow is as follow:
>
> The result underflows if a nonzero result value with ordinary accuracy
> would have magnitude (absolute value) less than the minimum normalized
> number in the type;
> however a zero result that is specified to be an exact zero does not
> underflow. Also, a result with ordinary accuracy and the magnitude of the
> minimum normalized number may underflow.274)
> If the result underflows, the function returns an implementation-defined
> value whose magnitude is no greater than the smallest normalized positive
> number in the specified type;
> *if the integer expression math_errhandling & MATH_ERRNO is nonzero,
> whether errno acquires the value ERANGE is implementation-defined;*
> *if the integer expression math_errhandling & MATH_ERREXCEPT is nonzero,
> whether the "underflow" floating-point exception is raised is
> implementation-defined.*
>
> So does it mean that the library implementation can choose to not raise the
> floating point exceptions in this case (and document the decision) and
> still conform to the standard?
My point is that the spec for nextafter concerning the exceptions
does no match the definition of these exceptions.
>From its definition, nextafter is always exact. Thus there should
have been no overflow/underflow/inexact exceptions, whose definition
is related to rounding.
--
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 / Pascaline project (LIP, ENS-Lyon)
More information about the cfp-interest
mailing list