1ECVT(P)                    POSIX Programmer's Manual                   ECVT(P)
2
3
4

NAME

6       ecvt, fcvt, gcvt - convert a floating-point number to a string (LEGACY)
7

SYNOPSIS

9       #include <stdlib.h>
10
11       char *ecvt(double value, int ndigit, int *restrict decpt,
12              int *restrict sign);
13       char *fcvt(double value, int ndigit, int *restrict decpt,
14              int *restrict sign);
15       char *gcvt(double value, int ndigit, char *buf);
16
17

DESCRIPTION

19       The  ecvt(),  fcvt(), and gcvt() functions shall convert floating-point
20       numbers to null-terminated strings.
21
22       The ecvt() function shall convert value to a null-terminated string  of
23       ndigit  digits  (where ndigit is reduced to an unspecified limit deter‐
24       mined by the precision of a double) and return a pointer to the string.
25       The high-order digit shall be non-zero, unless the value is 0. The low-
26       order digit shall be rounded in an implementation-defined  manner.  The
27       position of the radix character relative to the beginning of the string
28       shall be stored in the integer pointed to by decpt (negative  means  to
29       the  left  of the returned digits). If value is zero, it is unspecified
30       whether the integer pointed to by decpt would be  0  or  1.  The  radix
31       character  shall not be included in the returned string. If the sign of
32       the result is negative, the integer pointed to by sign  shall  be  non-
33       zero; otherwise, it shall be 0.
34
35       If  the  converted  value  is out of range or is not representable, the
36       contents of the returned string are unspecified.
37
38       The fcvt() function shall be equivalent to ecvt(), except  that  ndigit
39       specifies  the  number of digits desired after the radix character. The
40       total number of digits in the result string is restricted to an unspec‐
41       ified limit as determined by the precision of a double.
42
43       The  gcvt()  function  shall  convert value to a null-terminated string
44       (similar to that of the %g conversion specification format of printf())
45       in  the  array pointed to by buf and shall return buf. It shall produce
46       ndigit significant digits (limited to an unspecified  value  determined
47       by the precision of a double) in the %f conversion specification format
48       of printf() if possible, or the %e conversion specification  format  of
49       printf()  (scientific  notation)  otherwise.  A  minus  sign  shall  be
50       included in the returned string if value is less than 0. A radix  char‐
51       acter  shall be included in the returned string if value is not a whole
52       number.  Trailing zeros shall be suppressed where value is not a  whole
53       number.  The  radix  character  is determined by the current locale. If
54       setlocale() has not  been  called  successfully,  the  default  locale,
55       POSIX,  is  used.  The default locale specifies a period ( '.' ) as the
56       radix character.  The LC_NUMERIC category determines the value  of  the
57       radix character within the current locale.
58
59       These  functions need not be reentrant. A function that is not required
60       to be reentrant is not required to be thread-safe.
61

RETURN VALUE

63       The ecvt() and fcvt() functions shall return a pointer to a null-termi‐
64       nated string of digits.
65
66       The gcvt() function shall return buf.
67
68       The return values from ecvt() and fcvt() may point to static data which
69       may be overwritten by subsequent calls to these functions.
70

ERRORS

72       No errors are defined.
73
74       The following sections are informative.
75

EXAMPLES

77       None.
78

APPLICATION USAGE

80       The sprintf() function is preferred over this function.
81

RATIONALE

83       None.
84

FUTURE DIRECTIONS

86       These functions may be withdrawn in a future version.
87

SEE ALSO

89       printf()   ,   setlocale()   ,   the   Base   Definitions   volume   of
90       IEEE Std 1003.1-2001, <stdlib.h>
91
93       Portions  of  this text are reprinted and reproduced in electronic form
94       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
95       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
96       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
97       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
98       event of any discrepancy between this version and the original IEEE and
99       The  Open Group Standard, the original IEEE and The Open Group Standard
100       is the referee document. The original Standard can be  obtained  online
101       at http://www.opengroup.org/unix/online.html .
102
103
104
105IEEE/The Open Group                  2003                              ECVT(P)
Impressum