[Cfp-interest 2733] Re: comparison macros and exceptions due to conversion to the semantic type
Vincent Lefevre
vincent at vinc17.net
Tue Mar 28 02:15:03 PDT 2023
On 2023-03-27 21:01:25 -0700, Jim Thomas wrote:
> > and 7.12.17.6 "The isunordered macro" says
> >
> > It raises no floating-point exceptions if neither argument is a
> > signaling NaN.
> >
> > Now, if a conversion to the semantic type with the isunordered macro
> > yields an underflow or an overflow, is this exception expected to be
> > signaled? This seems unclear.
>
> I think the intention is that if the argument is represented in
> wider format and is converted to semantic type, then any overflow or
> underflow resulting from the conversion would be signaled. Such a
> conversion may be considered to be prior to the comparison (similar
> to argument conversion for a function). If the argument is not
> converted to semantic type, then overflow and underflow would not
> occur.
This may not be obvious for the implementer, who could do the
following, in case the code would be based on signaling operations
(more likely to be available natively):
1. Save the exception state (flags).
2. Compute the isunordered result with signaling operations.
3. Restore the exception state and add "invalid" if needed.
Step 2 could involve a conversion to the semantic type, e.g. by
first storing the macro arguments to variables. And with such a
code, the potential underflow and overflow exceptions would be
cleared at step 3.
--
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