[Cfp-interest 2736] Re: comparison macros and exceptions due to conversion to the semantic type

Jim Thomas jaswthomas at sbcglobal.net
Tue Mar 28 10:02:18 PDT 2023



> On Mar 28, 2023, at 2:15 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> 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.

Such an implementation would not conform to Annex F (F.10.14). Just noting.

If the current (7.12.17) spec isn’t clear, we could consider appending to footnote 303 (ref. N3054): "It is intended that any conversion of an argument to semantic type raise floating-point exceptions appropriate for the conversion."

- Jim Thomas

> 
> -- 
> 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)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the Cfp-interest mailing list