<div dir="ltr"><div>Greetings,</div><div><br></div><div>Joseph Myers has raised the issue of the sign of a zero result from the fromfp family of functions.</div><div class="gmail_quote gmail_quote_container"><div dir="ltr"><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>> Do the fromfp functions follow the same rules about the sign of a zero</div><div>> result as all the other functions rounding to an integer in a floating</div><div>> type (i.e., the sign of a zero result is the sign of the floating</div><div>> argument)? In particular, is it correct that the ufromfp functions return</div><div>> -0 when a negative argument rounds to 0? The issue of the sign of a zero</div><div>> result was introduced when we changed these functions to return a floating</div><div>> type for C23 (N2548), but we didn't add any text to the standard</div><div>> discussing it for these functions.</div></blockquote><div><br></div><div>Both the binary and decimal flavors of fromfp take an unsigned int parameter width. Depending on the possible prefix 'u', they specify an integral return value in the floating return type corresponding to an unsigned or a 2's complement signed binary width-bit integer. </div><div><br></div><div>In both unsigned and 2's complement integer representations, zero is mathematical, without algebraic sign. The natural behavior for fromfp is to return +0 when it returns zero, regardless of the input argument and choice of roundings. The integral result of fromfp is the canonical representation of the integer value in a normalized floating format.</div><div><br></div><div>This added wording would clarify the point.</div><div><br></div><div>Proposed change to 7.12.10.10p2:</div><div> From:</div><div> . . . then the functions return the integer value (represented in floating type).</div><div><div> To:</div><div> . . . then the functions return the integer value (represented in floating type); a zero return value is always +0.</div><div><br></div><div>The phrasing is designed to flow into the following conditional text.</div><div><br></div></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-Jerome Coonen<div> 650.996.4738</div><div> <a href="mailto:jcoonen@gmail.com" target="_blank">jcoonen@gmail.com</a></div></div></div></div></div>
</div></div>