1ecvt(3C)                 Standard C Library Functions                 ecvt(3C)
2
3
4

NAME

6       ecvt, fcvt, gcvt - convert floating-point number to string
7

SYNOPSIS

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

DESCRIPTION

21       The  ecvt(), fcvt() and gcvt() functions convert floating-point numbers
22       to null-terminated strings.
23
24   ecvt()
25       The ecvt() function converts  value  to  a  null-terminated  string  of
26       ndigit  digits  (where ndigit is reduced to an unspecified limit deter‐
27       mined by the precision of a  double)  and  returns  a  pointer  to  the
28       string.   The high-order digit is non-zero, unless the value is 0.  The
29       low-order digit is rounded.  The position of the radix character  rela‐
30       tive to the beginning of the string is stored in the integer pointed to
31       by decpt (negative means to the left of the returned digits). The radix
32       character  is  not  included in the returned string. If the sign of the
33       result is negative, the integer pointed to by sign is non-zero,  other‐
34       wise it is 0.
35
36
37       If  the  converted  value  is out of range or is not representable, the
38       contents of the returned string are unspecified.
39
40   fcvt()
41       The fcvt() function is identical to ecvt() except that ndigit specifies
42       the  number  of digits desired after the radix point.  The total number
43       of digits in the result string is restricted to an unspecified limit as
44       determined by the precision of a double.
45
46   gcvt()
47       The gcvt() function converts value to a null-terminated string (similar
48       to that of the %g format of printf(3C)) in the array pointed to by  buf
49       and  returns  buf. It produces ndigit significant digits (limited to an
50       unspecified value determined by the precision of a  double)  in  %f  if
51       possible,  or  %e  (scientific  notation)  otherwise.   A minus sign is
52       included in the returned string if value is less than 0.  A radix char‐
53       acter  is  included in the returned string if value is not a whole num‐
54       ber.  Trailing zeros are suppressed where value is not a whole  number.
55       The  radix  character  is  determined  by the current locale. If setlo‐
56       cale(3C) has not been called successfully, the default  locale,  POSIX,
57       is  used.  The default locale specifies a period (.) as the radix char‐
58       acter.  The LC_NUMERIC category determines the value of the radix char‐
59       acter within the current locale.
60

RETURN VALUES

62       The  ecvt()  and fcvt() functions return a pointer to a null-terminated
63       string of digits.
64
65
66       The gcvt() function returns buf.
67

ERRORS

69       No errors are defined.
70

USAGE

72       The return values from ecvt() and fcvt() might point to thread-specific
73       data  that can be overwritten by subsequent calls to these functions by
74       the same thread.
75
76
77       For portability to implementations conforming to  earlier  versions  of
78       Solaris, sprintf(3C) is preferred over this function.
79

ATTRIBUTES

81       See attributes(5) for descriptions of the following attributes:
82
83
84
85
86       ┌─────────────────────────────┬─────────────────────────────┐
87       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
88       ├─────────────────────────────┼─────────────────────────────┤
89       │Interface Stability          │Standard                     │
90       ├─────────────────────────────┼─────────────────────────────┤
91       │MT-Level                     │Safe                         │
92       └─────────────────────────────┴─────────────────────────────┘
93

SEE ALSO

95       printf(3C), setlocale(3C), sprintf(3C), attributes(5), standards(5)
96
97
98
99SunOS 5.11                        18 May 2004                         ecvt(3C)
Impressum