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

Jim Thomas jaswthomas at sbcglobal.net
Tue Mar 28 09:40:41 PDT 2023



> On Mar 27, 2023, at 9:01 PM, Jim Thomas <jaswthomas at sbcglobal.net> wrote:
> 
> 
> 
>> On Mar 27, 2023, at 8:03 PM, Vincent Lefevre <vincent at vinc17.net> wrote:
>> 
>> In N3088, 7.12.17 "Comparison macros" has note 302:
>> 
>> Whether an argument represented in a format wider than its
>> semantic type is converted to the semantic type is unspecified.
> 
> This is unfortunate. I’m guessing it got implemented both ways before the lack of specification was noticed, and the current statement just acknowledges the situation.

Annex F is more specific. F.10.14 says:

Relational operators and their corresponding comparison macros (7.12.17) produce equivalent result values, even if argument values are represented in wider formats. Thus, comparison macro arguments represented in formats wider than their semantic types are not converted to the semantic types, unless the wide evaluation method converts operands of relational operators to their semantic types. The standard wide evaluation methods characterized by FLT_EVAL_METHOD and DEC_EVAL_METHOD equal to 1 or 2 (5.2.4.2.2, 5.2.4.2.3), do not convert operands of relational operators to their semantic types.

- Jim Thomas

> 
>> 
>> 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.
> 
> - Jim Thomas
> 
>> 
>> Then, same question for the other comparison macros.
>> 
>> -- 
>> 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
> 
> 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230328/136a6cd0/attachment.htm>


More information about the Cfp-interest mailing list