<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Paul Zimmermann pointed out that correctly rounded library functions might yield a result that is outside the range of the corresponding mathematical function in cases where the range is an interval with an endpoint that is not representable in the format. However, specification of some functions in C 7.12 state that the function returns a value in such an interval. For example, 7.12.5.2 says</div><div><br></div><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div><b>Description</b></div><div>2 The <font face="Courier New">asin</font> functions compute the principal value of the arc sine of <i>x</i>. A domain error occurs for arguments not in the interval [−1, +1]. A range error occurs if nonzero <i>x</i> is too close to zero.</div><div><b>Returns</b></div><div>3 The <font face="Courier New">asin</font> functions return arcsin x in the interval [−π/2, +π/2] radians.</div></blockquote><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div></div></blockquote><div><br></div><div>Should C require its library function results to be in the range of the corresponding mathematical function when a correctly rounded result might not be?</div><div><br></div><div>As noted in previous email, regarding the similar situation for its atan operation, ISO/IEC 60559 9.2.1 says</div><div><br></div><div><div><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div></div></blockquote></div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;">For some formats under some rounding attributes the rounded magnitude range of <b>atan</b> (<b>atan2</b>) might exceed the unrounded magnitude of π/2 (π). A programmer must then take care to properly handle any anomalous manifold jump that might occur under the inverse operation.</blockquote><div><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div></div></blockquote></div><div><br></div><div>Thus, ISO/IEC 60559 prioritizes correct rounding over range bounds. I’m not aware of any place that ISO/IEC 60559 makes an exception to correct rounding for its floating-point operations to preserve a property of the corresponding mathematical operation.</div></div><div><br></div><div>The following rewrite of the <font face="Courier New">asin</font> specification above exemplifies a way to remove the range bound requirement:</div><div><div><br></div><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div></div></blockquote></div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div><b>Description</b></div><div>2 The <font face="Courier New">asin</font> functions compute the principal value of the arc sine of <i>x</i>, which is in the interval [−π/2, +π/2] radians. A domain error occurs for arguments not in the interval [−1, +1]. A range error occurs if nonzero <i>x</i> is too close to zero.</div><div><b>Returns</b></div><div>3 The <font face="Courier New">asin</font> functions return the principal value of arcsin x.</div></blockquote><div><div>---------</div><blockquote style="margin: 0px 0px 0px 40px; border: medium; padding: 0px;"><div></div></blockquote></div><div><br></div><div>A similar change can be made in the other relevant subclauses:</div><div><br></div><div>7.12.5.1 The <font face="Courier New">acos</font> functions</div><div>7.12.5.3 The <font face="Courier New">atan</font> functions</div><div>7.12.5.4 The <font face="Courier New">atan2</font> functions</div><div><br></div><div><br></div><div>- Jim Thomas</div><div><br></div><br class="Apple-interchange-newline"><div><br><blockquote type="cite"><div>On Aug 9, 2025, at 4:18 PM, Jim Thomas <jaswthomas@sbcglobal.net> wrote:</div><br class="Apple-interchange-newline"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">The issue for CFP is what to do about C specification that might be inconsistent with correct rounding, like 7.12.5.2 #3:<div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>The <font face="Courier New">asin</font> functions return arcsin <i>x</i> in the interval [−pi/2, +pi/2] radians.</div></div></blockquote><div><div><br></div><div>I think the purpose of the range qualification should be to identify the primary branch of the multivalued mathematical function, not to strictly bound the range of the library function.</div><div><br></div><div>- Jim Thomas</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Aug 9, 2025, at 3:39 PM, Jim Thomas <jaswthomas@sbcglobal.net> wrote:</div><br class="Apple-interchange-newline"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Paul,<div><br></div><div>Thanks for the correction!</div><div><br></div><div>Note that ISO/IEC 60559 9.2.1 says</div><div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>For some formats under some rounding attributes the rounded magnitude range of <b>atan</b> (<b>atan2</b>) might exceed the unrounded magnitude of π/2 (π). A programmer must then take care to properly handle any anomalous manifold jump that might occur under the inverse operation.</div></div></blockquote><div><br></div><div>prioritizing correct rounding over range bounds. I’m not aware of any place that ISO/IEC 60559 makes an exception to correct rounding for its floating-point operation to preserve a property of the corresponding mathematical operation. </div><div><br></div><div>- Jim</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Jul 18, 2025, at 11:36 PM, Paul Zimmermann <Paul.Zimmermann@inria.fr> wrote:</div><br class="Apple-interchange-newline"><div><div><blockquote type="cite">Correctly rounded functions, e.g. sqrt(x) per Annex F, won’t return out-of-range values. C reserves cr_ prefixed names for correctly rounded math functions.<br></blockquote><br>however correct rounding is not always compatible with range constraints,<br>see the example in section 6.4 from https://dl.acm.org/doi/pdf/10.1145/3747840.<br><br>Maybe the CFP group might decide what to do in that case.<br><br>Paul<br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></body></html>