| <html lang="en"> |
| <head> |
| <title>ecvt - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Stdlib.html#Stdlib" title="Stdlib"> |
| <link rel="prev" href="ecvtbuf.html#ecvtbuf" title="ecvtbuf"> |
| <link rel="next" href="_005f_005fenv_005flock.html#g_t_005f_005fenv_005flock" title="__env_lock"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="ecvt"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="_005f_005fenv_005flock.html#g_t_005f_005fenv_005flock">__env_lock</a>, |
| Previous: <a rel="previous" accesskey="p" href="ecvtbuf.html#ecvtbuf">ecvtbuf</a>, |
| Up: <a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">2.13 <code>ecvt</code>, <code>ecvtf</code>, <code>fcvt</code>, <code>fcvtf</code>—double or float to string</h3> |
| |
| <p><a name="index-ecvt-20"></a><a name="index-ecvtf-21"></a><a name="index-fcvt-22"></a><a name="index-fcvtf-23"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdlib.h> |
| |
| char *ecvt(double <var>val</var>, int <var>chars</var>, int *<var>decpt</var>, int *<var>sgn</var>); |
| char *ecvtf(float <var>val</var>, int <var>chars</var>, int *<var>decpt</var>, int *<var>sgn</var>); |
| |
| char *fcvt(double <var>val</var>, int <var>decimals</var>, |
| int *<var>decpt</var>, int *<var>sgn</var>); |
| char *fcvtf(float <var>val</var>, int <var>decimals</var>, |
| int *<var>decpt</var>, int *<var>sgn</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| <code>ecvt</code> and <code>fcvt</code> produce (null-terminated) strings of digits |
| representating the <code>double</code> number <var>val</var>. |
| <code>ecvtf</code> and <code>fcvtf</code> produce the corresponding character |
| representations of <code>float</code> numbers. |
| |
| <p>(The <code>stdlib</code> functions <code>ecvtbuf</code> and <code>fcvtbuf</code> are reentrant |
| versions of <code>ecvt</code> and <code>fcvt</code>.) |
| |
| <p>The only difference between <code>ecvt</code> and <code>fcvt</code> is the |
| interpretation of the second argument (<var>chars</var> or <var>decimals</var>). |
| For <code>ecvt</code>, the second argument <var>chars</var> specifies the total number |
| of characters to write (which is also the number of significant digits |
| in the formatted string, since these two functions write only digits). |
| For <code>fcvt</code>, the second argument <var>decimals</var> specifies the number of |
| characters to write after the decimal point; all digits for the integer |
| part of <var>val</var> are always included. |
| |
| <p>Since <code>ecvt</code> and <code>fcvt</code> write only digits in the output string, |
| they record the location of the decimal point in <code>*</code><var>decpt</var>, and |
| the sign of the number in <code>*</code><var>sgn</var>. After formatting a number, |
| <code>*</code><var>decpt</var> contains the number of digits to the left of the |
| decimal point. <code>*</code><var>sgn</var> contains <code>0</code> if the number is positive, |
| and <code>1</code> if it is negative. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| All four functions return a pointer to the new string containing a |
| character representation of <var>val</var>. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| None of these functions are ANSI C. |
| |
| <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>, |
| <code>lseek</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>. |
| |
| <p><br> |
| |
| <p><br> |
| |
| </body></html> |
| |