1ECVT(3) Linux Programmer's Manual ECVT(3)
2
3
4
6 ecvt, fcvt - convert a floating-point number to a string
7
9 #include <stdlib.h>
10
11 char *ecvt(double number, int ndigits, int *decpt, int *sign);
12
13 char *fcvt(double number, int ndigits, int *decpt, int *sign);
14
15 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
16
17 ecvt(), fcvt(): _SVID_SOURCE || _XOPEN_SOURCE >= 500
18
20 The ecvt() function converts number to a null-terminated string of
21 ndigits digits (where ndigits is reduced to a system-specific limit
22 determined by the precision of a double), and returns a pointer to the
23 string. The high-order digit is non-zero, unless number is zero. The
24 low order digit is rounded. The string itself does not contain a deci‐
25 mal point; however, the position of the decimal point relative to the
26 start of the string is stored in *decpt. A negative value for *decpt
27 means that the decimal point is to the left of the start of the string.
28 If the sign of number is negative, *sign is set to a non-zero value,
29 otherwise it is set to 0. If number is zero, it is unspecified whether
30 *decpt is 0 or 1.
31
32 The fcvt() function is identical to ecvt(), except that ndigits speci‐
33 fies the number of digits after the decimal point.
34
36 Both the ecvt() and fcvt() functions return a pointer to a static
37 string containing the ASCII representation of number. The static
38 string is overwritten by each call to ecvt() or fcvt().
39
41 SVr2; marked as LEGACY in POSIX.1-2001. POSIX.1-2008 removes the spec‐
42 ifications of ecvt() and fcvt(), recommending the use of sprintf(3)
43 instead (though snprintf(3) may be preferable).
44
46 Linux libc4 and libc5 specified the type of ndigits as size_t. Not all
47 locales use a point as the radix character ("decimal point").
48
50 ecvt_r(3), gcvt(3), qecvt(3), setlocale(3), sprintf(3)
51
53 This page is part of release 3.22 of the Linux man-pages project. A
54 description of the project, and information about reporting bugs, can
55 be found at http://www.kernel.org/doc/man-pages/.
56
57
58
59 2009-03-15 ECVT(3)