diff options
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Fnan.html')
| -rw-r--r-- | devdocs/c/numeric%2Fmath%2Fnan.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Fnan.html b/devdocs/c/numeric%2Fmath%2Fnan.html new file mode 100644 index 00000000..b8bdd8b4 --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Fnan.html @@ -0,0 +1,74 @@ + <h1 id="firstHeading" class="firstHeading">nan, nanf, nanl, nand32, nand64, nand128</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-c99"> <td> <pre data-language="c">float nanf( const char* arg );</pre> +</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double nan( const char* arg );</pre> +</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double nanl( const char* arg );</pre> +</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">_Decimal32 nand32( const char* arg );</pre> +</td> <td> (4) </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">_Decimal64 nand64( const char* arg );</pre> +</td> <td> (5) </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">_Decimal128 nand128( const char* arg );</pre> +</td> <td> (6) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> </table> <p>Converts the implementation-defined character string <code>arg</code> into the corresponding quiet NaN value, as if by calling the appropriate parsing function <code><i>strtoX</i></code>, as follows:</p> +<ul> +<li> The call <code>nan("n-char-sequence")</code>, where <span class="t-spar">n-char-sequence</span> is a sequence of digits, Latin letters, and underscores, is equivalent to the call <code><span class="coMULTI">/*strtoX*/</span><span class="br0">(</span><span class="st0">"NAN(n-char-sequence)"</span>, <span class="br0">(</span><span class="kw4">char</span><span class="sy2">**</span><span class="br0">)</span><a href="http://en.cppreference.com/w/c/types/NULL"><span class="kw103">NULL</span></a><span class="br0">)</span><span class="sy4">;</span></code>. </li> +<li> The call <code>nan("")</code> is equivalent to the call <code><span class="coMULTI">/*strtoX*/</span><span class="br0">(</span><span class="st0">"NAN()"</span>, <span class="br0">(</span><span class="kw4">char</span><span class="sy2">**</span><span class="br0">)</span><a href="http://en.cppreference.com/w/c/types/NULL"><span class="kw103">NULL</span></a><span class="br0">)</span><span class="sy4">;</span></code>. </li> +<li> The call <code>nan("string")</code>, where <code>string</code> is neither an <span class="t-spar">n-char-sequence</span> nor an empty string, is equivalent to the call <code><span class="coMULTI">/*strtoX*/</span><span class="br0">(</span><span class="st0">"NAN"</span>, <span class="br0">(</span><span class="kw4">char</span><span class="sy2">**</span><span class="br0">)</span><a href="http://en.cppreference.com/w/c/types/NULL"><span class="kw103">NULL</span></a><span class="br0">)</span><span class="sy4">;</span></code>. </li> +</ul> <div class="t-li1"> +<span class="t-li">1)</span> The parsing function is <code><a href="../../string/byte/strtof" title="c/string/byte/strtof">strtof</a></code>.</div> <div class="t-li1"> +<span class="t-li">2)</span> The parsing function is <code><a href="../../string/byte/strtof" title="c/string/byte/strtof">strtod</a></code>.</div> <div class="t-li1"> +<span class="t-li">3)</span> The parsing function is <code><a href="../../string/byte/strtof" title="c/string/byte/strtof">strtold</a></code>.</div> <div class="t-li1"> +<span class="t-li">4)</span> The parsing function is <code>strtod32</code>.</div> <div class="t-li1"> +<span class="t-li">5)</span> The parsing function is <code>strtod64</code>.</div> <div class="t-li1"> +<span class="t-li">6)</span> The parsing function is <code>strtod128</code>.</div> <table class="t-rev-begin"> <tr class="t-rev t-since-c23"> +<td> <p>The functions returning decimal floating point values are declared if and only the implementation predefines <code>__STDC_IEC_60559_DFP__</code> (i.e. the implementation supports decimal floating point numbers).</p> +</td> <td><span class="t-mark-rev t-since-c23">(since C23)</span></td> +</tr> </table> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> narrow character string identifying the contents of a NaN </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <p>The quiet NaN value that corresponds to the identifying string <code>arg</code> or zero if the implementation does not support quiet NaNs.</p> +<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559), it also supports quiet NaNs.</p> +<h3 id="Error_handling"> Error handling</h3> <p>This function is not subject to any of the error conditions specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> +#include <math.h> +#include <stdint.h> +#include <inttypes.h> +#include <string.h> + +int main(void) +{ + double f1 = nan("1"); + uint64_t f1n; memcpy(&f1n, &f1, sizeof f1); + printf("nan(\"1\") = %f (%" PRIx64 ")\n", f1, f1n); + + double f2 = nan("2"); + uint64_t f2n; memcpy(&f2n, &f2, sizeof f2); + printf("nan(\"2\") = %f (%" PRIx64 ")\n", f2, f2n); + + double f3 = nan("0xF"); + uint64_t f3n; memcpy(&f3n, &f3, sizeof f3); + printf("nan(\"0xF\") = %f (%" PRIx64 ")\n", f3, f3n); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">nan("1") = nan (7ff8000000000001) +nan("2") = nan (7ff8000000000002) +nan("0xF") = nan (7ff800000000000f)</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul> +<li> 7.12.11.2 The nan functions (p: 186-187) </li> +<li> F.10.8.2 The nan functions (p: 386) </li> +</ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 7.12.11.2 The nan functions (p: 256) </li> +<li> F.10.8.2 The nan functions (p: 529) </li> +</ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul> +<li> 7.12.11.2 The nan functions (p: 237) </li> +<li> F.9.8.2 The fabs functions (p: 465) </li> +</ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="isnan" title="c/numeric/math/isnan"> <span class="t-lines"><span>isnan</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> checks if the given number is NaN <br> <span class="t-mark">(function macro)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="nan" title="c/numeric/math/NAN"> <span class="t-lines"><span>NAN</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> evaluates to a quiet NaN of type <code>float</code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/nan" title="cpp/numeric/math/nan">C++ documentation</a></span> for <code>nanf, nan, nanl</code> </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/nan" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/nan</a> + </p> +</div> |
