diff options
| author | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-08-14 22:58:58 -0500 |
| commit | 82ba818ff456bcd6d56a06226e3f27e98fbb55c3 (patch) | |
| tree | 158cfc17b2f644a10f063cb546752cfaae12c97f /devdocs/c/string%2Fbyte%2Fstrtof.html | |
| parent | 9278ddd4ea1a8b1a4c1edaa8894516e3f48d245b (diff) | |
| download | dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.tar.gz dotemacs-82ba818ff456bcd6d56a06226e3f27e98fbb55c3.zip | |
removing all downloaded devdocs files
Diffstat (limited to 'devdocs/c/string%2Fbyte%2Fstrtof.html')
| -rw-r--r-- | devdocs/c/string%2Fbyte%2Fstrtof.html | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/devdocs/c/string%2Fbyte%2Fstrtof.html b/devdocs/c/string%2Fbyte%2Fstrtof.html deleted file mode 100644 index b3be49b7..00000000 --- a/devdocs/c/string%2Fbyte%2Fstrtof.html +++ /dev/null @@ -1,90 +0,0 @@ - <h1 id="firstHeading" class="firstHeading">strtof, strtod, strtold</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><stdlib.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float strtof( const char *restrict str, char **restrict str_end );</pre> -</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-until-c99"> <td><pre data-language="c">double strtod( const char *str, char **str_end );</pre></td> <td class="t-dcl-nopad"> </td> <td><span class="t-mark-rev t-until-c99">(until C99)</span></td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double strtod( const char *restrict str, char **restrict str_end );</pre> -</td> <td class="t-dcl-nopad"> </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 strtold( const char *restrict str, char **restrict str_end );</pre> -</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <p>Interprets a floating-point value in a byte string pointed to by <code>str</code>.</p> -<p>Function discards any whitespace characters (as determined by <code><a href="isspace" title="c/string/byte/isspace">isspace</a></code>) until first non-whitespace character is found. Then it takes as many characters as possible to form a valid floating-point representation and converts them to a floating-point value. The valid floating-point value can be one of the following:</p> -<ul> -<li>decimal floating-point expression. It consists of the following parts: </li> -<ul> -<li> <span class="t-mark">(optional)</span> plus or minus sign </li> -<li> nonempty sequence of decimal digits optionally containing decimal-point character (as determined by the current C <a href="../../locale/setlocale" title="c/locale/setlocale">locale</a>) (defines significand) </li> -<li> <span class="t-mark">(optional)</span> <code>e</code> or <code>E</code> followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent to base 10) </li> -</ul> -</ul> <table class="t-rev-begin"> <tr class="t-rev t-since-c99"> -<td> <ul> -<li>hexadecimal floating-point expression. It consists of the following parts: </li> -<ul> -<li> <span class="t-mark">(optional)</span> plus or minus sign </li> -<li> <code>0x</code> or <code>0X</code> </li> -<li> nonempty sequence of hexadecimal digits optionally containing a decimal-point character (as determined by the current C <a href="../../locale/setlocale" title="c/locale/setlocale">locale</a>) (defines significand) </li> -<li> <span class="t-mark">(optional)</span> <code>p</code> or <code>P</code> followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent to base 2) </li> -</ul> -<li> infinity expression. It consists of the following parts: </li> -<ul> -<li> <span class="t-mark">(optional)</span> plus or minus sign </li> -<li> <code>INF</code> or <code>INFINITY</code> ignoring case </li> -</ul> -<li> not-a-number expression. It consists of the following parts: </li> -<ul> -<li> <span class="t-mark">(optional)</span> plus or minus sign </li> -<li> <code>NAN</code> or <code>NAN(</code><i>char_sequence</i><code>)</code> ignoring case of the <code>NAN</code> part. <i>char_sequence</i> can only contain digits, Latin letters, and underscores. The result is a quiet NaN floating-point value. </li> -</ul> -</ul> </td> <td><span class="t-mark-rev t-since-c99">(since C99)</span></td> -</tr> </table> <ul><li> any other expression that may be accepted by the currently installed C <a href="../../locale/setlocale" title="c/locale/setlocale">locale</a> </li></ul> <p>The functions sets the pointer pointed to by <code>str_end</code> to point to the character past the last character interpreted. If <code>str_end</code> is a null pointer, it is ignored.</p> -<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> str </td> <td> - </td> <td> pointer to the null-terminated byte string to be interpreted </td> -</tr> <tr class="t-par"> <td> str_end </td> <td> - </td> <td> pointer to a pointer to character. </td> -</tr> -</table> <h3 id="Return_value"> Return value</h3> <p>Floating-point value corresponding to the contents of <code>str</code> on success. If the converted value falls out of range of corresponding return type, range error occurs (<code><a href="../../error/errno" title="c/error/errno">errno</a></code> is set to <code><a href="../../error/errno_macros" title="c/error/errno macros">ERANGE</a></code>) and <code><a href="../../numeric/math/huge_val" title="c/numeric/math/HUGE VAL">HUGE_VAL</a></code>, <code><a href="../../numeric/math/huge_val" title="c/numeric/math/HUGE VAL">HUGE_VALF</a></code> or <code><a href="../../numeric/math/huge_val" title="c/numeric/math/HUGE VAL">HUGE_VALL</a></code> is returned. If no conversion can be performed, <code>0</code> is returned.</p> -<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> -#include <errno.h> -#include <stdlib.h> - -int main(void) -{ - // parsing with error handling - const char *p = "111.11 -2.22 Nan nan(2) inF 0X1.BC70A3D70A3D7P+6 1.18973e+4932zzz"; - printf("Parsing '%s':\n", p); - char *end; - for (double f = strtod(p, &end); p != end; f = strtod(p, &end)) - { - printf("'%.*s' -> ", (int)(end-p), p); - p = end; - if (errno == ERANGE){ - printf("range error, got "); - errno = 0; - } - printf("%f\n", f); - } - - // parsing without error handling - printf("\" -0.0000000123junk\" --> %g\n", strtod(" -0.0000000123junk", NULL)); - printf("\"junk\" --> %g\n", strtod("junk", NULL)); -}</pre></div> <p>Possible output:</p> -<div class="text source-text"><pre data-language="c">Parsing '111.11 -2.22 Nan nan(2) inF 0X1.BC70A3D70A3D7P+6 1.18973e+4932zzz': -'111.11' -> 111.110000 -' -2.22' -> -2.220000 -' Nan' -> nan -' nan(2)' -> nan -' inF' -> inf -' 0X1.BC70A3D70A3D7P+6' -> 111.110000 -' 1.18973e+4932' -> range error, got inf -" -0.0000000123junk" --> -1.23e-08 -"junk" --> 0</pre></div> </div> <h3 id="References"> References</h3> <ul> -<li> C17 standard (ISO/IEC 9899:2018): </li> -<ul><li> 7.22.1.3 The strtod, strtof, and strtold functions (p: 249-251) </li></ul> -<li> C11 standard (ISO/IEC 9899:2011): </li> -<ul><li> 7.22.1.3 The strtod, strtof, and strtold functions (p: 342-344) </li></ul> -<li> C99 standard (ISO/IEC 9899:1999): </li> -<ul><li> 7.20.1.3 The strtod, strtof, and strtold functions (p: 308-310) </li></ul> -<li> C89/C90 standard (ISO/IEC 9899:1990): </li> -<ul><li> 4.10.1.4 The strtod function </li></ul> -</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="atof" title="c/string/byte/atof"> <span class="t-lines"><span>atof</span></span></a></div> </td> <td> converts a byte string to a floating-point value <br> <span class="t-mark">(function)</span> </td> -</tr> <tr class="t-dsc"> <td> <div><a href="../wide/wcstof" title="c/string/wide/wcstof"> <span class="t-lines"><span>wcstof</span><span>wcstod</span><span>wcstold</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-c95">(C95)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> converts a wide string to a floating-point value <br> <span class="t-mark">(function)</span> </td> -</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/byte/strtof" title="cpp/string/byte/strtof">C++ documentation</a></span> for <code>strtof, strtod, strtold</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/string/byte/strtof" class="_attribution-link">https://en.cppreference.com/w/c/string/byte/strtof</a> - </p> -</div> |
