<div dir="ltr"><div>This note addresses this 15 Oct action item carried over to 29 Oct:</div><div class="gmail_quote gmail_quote_container"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Follow up on cfp3618 to see whether snan issues apply to more than signbit, and what to do about it.</div><div><br></div></blockquote><div>(1) First, let's look at Damian's suggestion in cfp3618 to clarify F.3p7:</div><div><br></div><div>         ...This applies to all values, including <<<both quiet and signaling>>> NaNs<<<,>>> whose sign bit is not generally interpreted by ISO/IEC 60559.</div><div><br></div><div>The angle brackets denote changes.The added comma clarifies that the following phrase is informational, applying to all NaNs. </div><div><br></div><div>The mention of "both quiet and signaling" NaNs is arguable. F.2.2p2, quoted below, states that "NaN" refers to a quiet NaN unless stated otherwise. In this case, both flavors of NaN are intended. However, the next sentence of F.2.2p2 goes on to specify what to do with signaling NaNs, which addresses the signbit macro at hand. Are the extra words really needed?</div><div><br></div><div>In our meetings, we generally agree to avoid unneeded explanations, which can leave a reader wondering, "Why aren't signaling NaNs called out here, if they were called out there?" In this case (and after reviewing the hundreds of occurrences of "NaN" for context), it seems friendly to add the explanatory words.</div><div><br></div></div></div><div class="gmail_quote"><div dir="ltr"><div>(2) The copysign functions are another set of sign operations of interest. Section 7.12.12.1 specifies behavior consistent with 60559, with F.2.2p3 once again resolving the behavior with signaling NaNs. F.10.9.1 further specifies that there be no errors, also consistent with 60559.</div><div><br></div><div>(3)The fabs functions are similar in spirit to copysign.</div><div><br></div><div>My conclusion is that C2Y handles NaNs unambiguously for all implementations and consistently with 60559 when that is relevant. The proposed changes relative to cfp3618 will be an improvement.</div><div><br></div><div>-Jerome Coonen</div><div><br></div><div>---------------------------------------------------------</div><div>READER'S GUIDE of relevant excerpts on signaling NaNs from draft n3685. Please refer to 6.3 "The sign bit" in 60559 for some perspective from the point of view from the floating point standard. </div><div><br></div><div>5.3.5.3.3p10-11  -- Characteristics of floating types (a subclause referred to many times)</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>... a <span style="background-color:rgb(255,255,0)">signaling</span> NaN generally raises a floating-point exception when occurring as an arithmetic operand.</div></blockquote></div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>NOTE 2 ISO/IEC 60559 specifies quiet and <span style="background-color:rgb(255,255,0)">signaling</span> NaNs. For implementations that do not support ISO/IEC 60559, the terms quiet NaN and <span style="background-color:rgb(255,255,0)">signaling</span> NaN are intended to apply to values with similar behavior.</div></blockquote><div><br></div><div>7.12.2p3 -- Treatment of error conditions, domain error paragraph</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>...Whether a <span style="background-color:rgb(255,255,0)">signaling</span> NaN input causes a domain error is implementation-defined. ...</div></blockquote><div><div><br>7.12.4 Classification macros:</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">fpclassify<br>iscanonical<br>isfinite<br>isinf<br>isnan<br>isnormal<br>signbit<br>issignaling
<br>issubnormal<div><div>iszero</div></div></blockquote><div><div><br></div></div><div>7.12.4.9p3 -- The issignaling macro</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>The issignaling macro returns a nonzero value if and only if its argument is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.282)</div></blockquote><div><br></div><div>7.12.4.9 footnote 282</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>282) F.3 specifies that issignaling (and all the other classification macros), raise no floating-point exception if the argument is a variable, or any other expression whose value is represented in the format of its semantic type, even if the value is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.</div></blockquote><div><div><br>7.12.12 Manipulation functions:</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>copysign</div></div></blockquote><div><br></div><div>7.12.18.2p2 (and several similar comparison cases which raise "invalid" only if they have an snan operand)</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>...However, unlike (x) > (y), isgreater(x,y) does not raise the "invalid" floating-point exception when x and y are unordered and neither is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.</div></blockquote><div><div>    </div><div>F2.2p3 -- Infinities and NaNs</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>This annex does not require the full support for <span style="background-color:rgb(255,255,0)">signaling</span> NaNs specified in ISO/IEC 60559. This annex uses the term NaN, unless explicitly qualified, to denote quiet NaNs. Where specification of <span style="background-color:rgb(255,255,0)">signaling</span> NaNs is not provided, the behavior of signaling NaNs is implementation-defined (either treated as an ISO/IEC 60559 quiet NaN or treated as an ISO/IEC 60559 <span style="background-color:rgb(255,255,0)">signaling</span> NaN).436)</div></div></blockquote><div><div><br></div><div>F.2.2p5-7</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>To support <span style="background-color:rgb(255,255,0)">signaling</span> NaNs as specified in ISO/IEC 60559, an implementation should adhere to the following recommended practice.</div></div><div><div><br></div></div><div><div>Recommended practice</div></div><div><div><br></div></div><div><div>Any floating-point operator or <math.h> function or macro with a <span style="background-color:rgb(255,255,0)">signaling</span> NaN input, unless explicitly specified otherwise, raises an "invalid" floating-point exception.</div></div><div><div><br></div></div><div><div>NOTE Some functions do not propagate quiet NaN arguments. For example, hypot(x, y) returns infinity if x or y is infinite and the other is a quiet NaN. The recommended practice in this subclause specifies that such functions (and others) raise the "invalid" floating-point exception if an argument is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN, which also implies they return a quiet NaN in these cases.</div></div><div><br></div></blockquote><div>F.3p5-7 Operations</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>The unary + and - operators raise no floating-point exceptions, even if the operand is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.</div><div><br></div><div>The C classification macros fpclassify, iscanonical, isfinite, isinf, isnan, isnormal, issignaling, issubnormal, iszero, and signbit provide the ISO/IEC 60559 operations indicated in Table F.2 provided their arguments are in the format of their semantic type. Then these macros raise no floating-point exceptions, even if an argument is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.</div><div><br>The signbit macro, providing the ISO/IEC 60559 isSignMinus operation, determines the sign of its argument value as the sign bit of the value’s representation. This applies to all values, including NaNs whose sign bit is not generally interpreted by ISO/IEC 60559.</div></blockquote><div><br></div>F.10.5.3p2 The fabs functions<br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>fabs(x) raises no floating-point exceptions, even if x is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN.</div><div><br></div></blockquote>F.10.9.1p1 The copysign functions<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>copysign(x, y) raises no floating-point exceptions, even if x or y is a <span style="background-color:rgb(255,255,0)">signaling</span> NaN. The returned value is independent of the current rounding direction mode.</div></blockquote><div><div>-----------------------------------------</div><div><br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"></div></div></div></div></div>
</div></div>
</div></div>
</div></div>
</div></div>