<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div>For the Summary, I suggest saying more about why we’re recommending a change. The WG14 consideration of removing [u]intmax_t, sparked the CFP discussion. I think we concluded that changing the interfaces to not use [u]intmax_t would be better anyway (even if [u]intmax_t were not removed). Introducing type [u]intmax_t into an expression via a function return type could have unpredictable negative performance implications. For the compoundn, pown, and rootn functions, long long int appears to be more than adequate for applications.</div><div><br class=""></div><div>The changes to compoundn, pown, and rootn seem straightforward. On further thought, the change to the fromfp functions does not. For example, what would the functions do if the input does not round to an integer of the given width? </div><div><br class=""></div><div><div>The key point for IEC 60559 binding is that composing the function with a cast (or assignment) of the result to the desired integer type must have the behavior of the corresponding IEC 60559 conversion from floating-point to integer operation. For example, to convert from double to int128_t using to-nearest rounding without inexact, do</div><div><br class=""></div><div>double d;</div><div>int128_t i128;</div><div>i128 = fromfp(d, FE_INT_UPWARD, INT128_WIDTH);</div><div><br class=""></div><div>In the process of rewriting the Description for the fromfp functions, I wondered ... </div><div class=""><br class=""></div></div><div>Do we already have this functionality (without the fromfp functions)? For example, could the conversion above be done with</div><div><br class=""></div><div><div>double d;</div><div>int128_t i128;</div><div>{</div><div> #pragma STDC FENV_ROUND FE_UPWARD</div><div> i128 =nearbyint(d); // or rint to raise inexact</div><div>}</div><div><br class=""></div><div>The nearbyint rounds to integer value using the given rounding direction, and preserves infinities and NaNs. The assignment to i128 will raise invalid if the function result is infinite, NaN, or out of range.</div><div><br class=""></div><div>Does this handle all the edge cases (infinities, NaNs, our of range values, exceptions) per IEC 60559? Does the scheme work for the combinations of floating and (signed and unsigned) integer types? If so, would this be an acceptable binding?</div><div><br class=""></div></div><div>- Jim Thomas</div><div><blockquote type="cite" class=""><br class="webkit-block-placeholder"></blockquote></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 22, 2020, at 3:01 PM, Fred J. Tydeman <<a href="mailto:tydeman@tybor.com" class="">tydeman@tybor.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On Fri, 19 Jun 2020 10:11:01 -0700 (PDT) Fred J. Tydeman wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">intmax_t removal: *from* return FP type same as argument.<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Attached is a first pass on just some of the functions.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">If you are happy with the direction, I will add the others.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">---</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Fred J. Tydeman Tydeman Consulting</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:tydeman@tybor.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">tydeman@tybor.com</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span> Testing, numerics, programming</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">+1 (702) 608-6093 Vice-chair of PL22.11 (ANSI "C")</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Sample C99+FPCE tests:<span class="Apple-converted-space"> </span></span><a href="http://www.tybor.com/" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://www.tybor.com</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Savers sleep well, investors eat well, spenders work forever.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""><b class="">Submitter:</b>Fred J. Tydeman<br class=""><b class="">Submission Date:</b><span class="Apple-converted-space"> </span>2020-mm-dd<br class=""><b class="">Document:</b><span class="Apple-converted-space"> </span>WG14 N2xxx<br class=""><b class="">Title:</b><span class="Apple-converted-space"> </span>N2xxx: intmax_t and math functions<br class=""><b class="">Reference Documents:</b><span class="Apple-converted-space"> </span>N2478</p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Summary</p><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Due to issues raised by the WG14 committee with [u]intmax_t, several of the CFP related functions ([u]fromfp[x], compoundn, pown, rootn) should be changed to not use [u]intmax_t. In general, replace [u]intmax_t with the floating type used as the parameter.</span><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Change</p><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">7.12.9.10 The fromfp and ufromfp functions</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Synopsis</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><pre class=""><code class="">
1 #include <stdint.h>
#include <math.h>
intmax_t fromfp(double x, int round, unsigned int width);
intmax_t fromfpf(float x, int round, unsigned int width);
intmax_t fromfpl(long double x, int round, unsigned int width);
uintmax_t ufromfp(double x, int round, unsigned int width);
uintmax_t ufromfpf(float x, int round, unsigned int width);
uintmax_t ufromfpl(long double x, int round, unsigned int width);
#ifdef __STDC_IEC_60559_DFP__
intmax_t fromfpd32(_Decimal32 x, int round, unsigned int width);
intmax_t fromfpd64(_Decimal64 x, int round, unsigned int width);
intmax_t fromfpd128(_Decimal128 x, int round, unsigned int width);
uintmax_t ufromfpd32(_Decimal32 x, int round, unsigned int width);
uintmax_t ufromfpd64(_Decimal64 x, int round, unsigned int width);
uintmax_t ufromfpd128(_Decimal128 x, int round, unsigned int width);
#endif
</code>
</pre></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Description</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">2 The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions round x, using the math rounding direction indicated by<span class="Apple-converted-space"> </span><b class="">round</b>, to a signed or unsigned integer, respectively, of<span class="Apple-converted-space"> </span><b class="">width</b><span class="Apple-converted-space"> </span>bits, and return the result value in the integer type designated by<span class="Apple-converted-space"> </span><b class="">intmax_t</b><span class="Apple-converted-space"> </span>or<span class="Apple-converted-space"> </span><b class="">uintmax_t</b>, respectively. If the value of the<span class="Apple-converted-space"> </span><b class="">round</b><span class="Apple-converted-space"> </span>argument is not equal to the value of a math rounding direction macro, the direction of rounding is unspecified. If the value of<span class="Apple-converted-space"> </span><b class="">width</b><span class="Apple-converted-space"> </span>exceeds the width of the function type, the rounding is to the full width of the function type. The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions do not raise the "inexact" floating-point exception. If x is infinite or NaN or rounds to an integral value that is outside the range of any supported integer type of the specified width, or if width is zero, the functions return an unspecified value and a domain error occurs.</p></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">3 Returns</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions return the rounded integer value.</p></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">4 EXAMPLE Upward rounding of double x to type int, without raising the "inexact" floating-point exception, is achieved by</p><pre class=""><code class="">
(int)fromfp(x, FP_INT_UPWARD, INT_WIDTH)
</code>
</pre></blockquote><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">to</p><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">7.12.9.10 The fromfp and ufromfp functions</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Synopsis</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><pre class=""><code class="">
1 #include <stdint.h>
#include <math.h>
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">double</ins> fromfp(double x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">float</ins> fromfpf(float x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">long double</ins> fromfpl(long double x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">double</ins> ufromfp(double x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">float</ins> ufromfpf(float x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">long double</ins> ufromfpl(long double x, int round, unsigned int width);
#ifdef __STDC_IEC_60559_DFP__
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal32</ins> fromfpd32(_Decimal32 x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal64</ins> fromfpd64(_Decimal64 x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">intmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal128</ins> fromfpd128(_Decimal128 x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal32</ins> ufromfpd32(_Decimal32 x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal64</ins> ufromfpd64(_Decimal64 x, int round, unsigned int width);
<del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">uintmax_t</del> <ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">_Decimal128</ins> ufromfpd128(_Decimal128 x, int round, unsigned int width);
#endif
</code>
</pre></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Description</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">2 The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions round x, using the math rounding direction indicated by<span class="Apple-converted-space"> </span><b class="">round</b>, to a signed or unsigned integer, respectively, of<span class="Apple-converted-space"> </span><b class="">width</b><span class="Apple-converted-space"> </span>bits, and return the result value<span class="Apple-converted-space"> </span><del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">in the integer type designated by<span class="Apple-converted-space"> </span><b class="">intmax_t</b><span class="Apple-converted-space"> </span>or<span class="Apple-converted-space"> </span><b class="">uintmax_t</b>, respectively</del><ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">as in integer in floating-point format</ins>. If the value of the<span class="Apple-converted-space"> </span><b class="">round</b><span class="Apple-converted-space"> </span>argument is not equal to the value of a math rounding direction macro, the direction of rounding is unspecified. If the value of<span class="Apple-converted-space"> </span><b class="">width</b><span class="Apple-converted-space"> </span>exceeds the width of the function type, the rounding is to the full width of the function type. The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions do not raise the "inexact" floating-point exception. If x is infinite or NaN or rounds to an integral value that is outside the range of any supported integer type of the specified width, or if width is zero, the functions return<span class="Apple-converted-space"> </span><del style="font-weight: bold; background-color: rgb(255, 160, 160);" class="">an unspecified value</del><ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">a NaN (if available, else HUGE_VAL)</ins><span class="Apple-converted-space"> </span>and a domain error occurs.</p></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">3 Returns</blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">The<span class="Apple-converted-space"> </span><b class="">fromfp</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">ufromfp</b><span class="Apple-converted-space"> </span>functions return the rounded integer value.</p></blockquote><blockquote style="display: block; font-family: "Times New Roman"; background-color: lightgray; margin: 1em 40px; caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><p class="">4 EXAMPLE Upward rounding of double x to type int, without raising the "inexact" floating-point exception<ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">; unsigned wrapping is not performed in the second call</ins>, is achieved by</p><pre class=""><code class="">
(int)fromfp(x, FP_INT_UPWARD, INT_WIDTH)
<ins style="font-weight: bold; background-color: rgb(160, 255, 160);" class="">fromfp(-3.0, FP_INT_UPWARD, UINT_WIDTH) /* domain error */</ins>
</code>
</pre></blockquote><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Cfp-interest mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:Cfp-interest@oakapple.net" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Cfp-interest@oakapple.net</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="http://mailman.oakapple.net/mailman/listinfo/cfp-interest" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://mailman.oakapple.net/mailman/listinfo/cfp-interest</a></div></blockquote></div><br class=""></body></html>