diff options
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Froundeven.html')
| -rw-r--r-- | devdocs/c/numeric%2Fmath%2Froundeven.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Froundeven.html b/devdocs/c/numeric%2Fmath%2Froundeven.html new file mode 100644 index 00000000..418b93ae --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Froundeven.html @@ -0,0 +1,57 @@ + <h1 id="firstHeading" class="firstHeading">roundeven, roundevenf, roundevenl</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><math.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">float roundevenf( float arg );</pre> +</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">double roundeven( double arg );</pre> +</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">long double roundevenl( long double arg );</pre> +</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code><tgmath.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">#define roundeven( arg )</pre> +</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> </table> <div class="t-li1"> +<span class="t-li">1-3)</span> Computes the nearest integer value to <code>arg</code> (in floating-point format), rounding halfway cases to nearest even integer, regardless of the current rounding mode.</div> <div class="t-li1"> +<span class="t-li">4)</span> Type-generic macro: If <code>arg</code> has type <code>long double</code>, <code>roundevenl</code> is called. Otherwise, if <code>arg</code> has integer type or the type <code>double</code>, <code>roundeven</code> is called. Otherwise, <code>roundevenf</code> is called, respectively.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> floating point value </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the nearest integer value to <code>arg</code>, rounding halfway cases to nearest even integer, is returned.</p> +<h3 id="Error_handling"> Error handling</h3> <p>This function is not subject to any of the errors specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p> +<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559),</p> +<ul> +<li> <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INEXACT</a></code> is never raised </li> +<li> If <code>arg</code> is ±∞, it is returned, unmodified </li> +<li> If <code>arg</code> is ±0, it is returned, unmodified </li> +<li> If <code>arg</code> is NaN, NaN is returned </li> +</ul> <h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <math.h> +#include <stdio.h> +int main(void) +{ + printf("roundeven(+2.4) = %+.1f\n", roundeven(2.4)); + printf("roundeven(-2.4) = %+.1f\n", roundeven(-2.4)); + printf("roundeven(+2.5) = %+.1f\n", roundeven(2.5)); + printf("roundeven(-2.5) = %+.1f\n", roundeven(-2.5)); + printf("roundeven(+2.6) = %+.1f\n", roundeven(2.6)); + printf("roundeven(-2.6) = %+.1f\n", roundeven(-2.6)); + printf("roundeven(+3.5) = %+.1f\n", roundeven(3.5)); + printf("roundeven(-3.5) = %+.1f\n", roundeven(-3.5)); + printf("roundeven(-0.0) = %+.1f\n", roundeven(-0.0)); + printf("roundeven(-Inf) = %+f\n", roundeven(-INFINITY)); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">roundeven(+2.4) = +2.0 +roundeven(-2.4) = -2.0 +roundeven(+2.5) = +2.0 +roundeven(-2.5) = -2.0 +roundeven(+2.6) = +3.0 +roundeven(-2.6) = -3.0 +roundeven(+3.5) = +4.0 +roundeven(-3.5) = -4.0 +roundeven(-0.0) = -0.0 +roundeven(-Inf) = -inf</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C23 standard (ISO/IEC 9899:2023): </li> +<ul> +<li> 7.12.9.8 The roundeven functions (p: 265-266) </li> +<li> 7.27 Type-generic math <tgmath.h> (p: 386-390) </li> +<li> F.10.6.8 The roundeven functions (p: 532) </li> +</ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="rint" title="c/numeric/math/rint"> <span class="t-lines"><span>rint</span><span>rintf</span><span>rintl</span><span>lrint</span><span>lrintf</span><span>lrintl</span><span>llrint</span><span>llrintf</span><span>llrintl</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> rounds to an integer using current rounding mode with <br> exception if the result differs <br> <span class="t-mark">(function)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="round" title="c/numeric/math/round"> <span class="t-lines"><span>round</span><span>roundf</span><span>roundl</span><span>lround</span><span>lroundf</span><span>lroundl</span><span>llround</span><span>llroundf</span><span>llroundl</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> rounds to nearest integer, rounding away from zero in halfway cases <br> <span class="t-mark">(function)</span> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/numeric/math/roundeven" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/roundeven</a> + </p> +</div> |
