1ECVT(3)                    Linux Programmer's Manual                   ECVT(3)
2
3
4

NAME

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

SYNOPSIS

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():
18           Since glibc 2.12:
19               (_XOPEN_SOURCE >= 500) ! (_POSIX_C_SOURCE >= 200112L)
20                   || /* Glibc since 2.19: */ _DEFAULT_SOURCE
21                   || /* Glibc versions <= 2.19: */ _SVID_SOURCE
22           Before glibc 2.12:
23               _SVID_SOURCE || _XOPEN_SOURCE >= 500
24

DESCRIPTION

26       The  ecvt()  function  converts  number  to a null-terminated string of
27       ndigits digits (where ndigits is reduced  to  a  system-specific  limit
28       determined  by the precision of a double), and returns a pointer to the
29       string.  The high-order digit is nonzero, unless number is  zero.   The
30       low order digit is rounded.  The string itself does not contain a deci‐
31       mal point; however, the position of the decimal point relative  to  the
32       start  of  the string is stored in *decpt.  A negative value for *decpt
33       means that the decimal point is to the left of the start of the string.
34       If  the  sign  of  number is negative, *sign is set to a nonzero value,
35       otherwise it is set to 0.  If number is zero, it is unspecified whether
36       *decpt is 0 or 1.
37
38       The  fcvt() function is identical to ecvt(), except that ndigits speci‐
39       fies the number of digits after the decimal point.
40

RETURN VALUE

42       Both the ecvt() and fcvt() functions  return  a  pointer  to  a  static
43       string  containing  the  ASCII  representation  of  number.  The static
44       string is overwritten by each call to ecvt() or fcvt().
45

ATTRIBUTES

47       For  an  explanation  of  the  terms  used   in   this   section,   see
48       attributes(7).
49
50       ┌──────────┬───────────────┬─────────────────────┐
51Interface Attribute     Value               
52       ├──────────┼───────────────┼─────────────────────┤
53ecvt()    │ Thread safety │ MT-Unsafe race:ecvt │
54       ├──────────┼───────────────┼─────────────────────┤
55fcvt()    │ Thread safety │ MT-Unsafe race:fcvt │
56       └──────────┴───────────────┴─────────────────────┘

CONFORMING TO

58       SVr2; marked as LEGACY in POSIX.1-2001.  POSIX.1-2008 removes the spec‐
59       ifications of ecvt() and fcvt(), recommending  the  use  of  sprintf(3)
60       instead (though snprintf(3) may be preferable).
61

NOTES

63       Not all locales use a point as the radix character ("decimal point").
64

SEE ALSO

66       ecvt_r(3), gcvt(3), qecvt(3), setlocale(3), sprintf(3)
67

COLOPHON

69       This  page  is  part of release 4.15 of the Linux man-pages project.  A
70       description of the project, information about reporting bugs,  and  the
71       latest     version     of     this    page,    can    be    found    at
72       https://www.kernel.org/doc/man-pages/.
73
74
75
76                                  2016-03-15                           ECVT(3)
Impressum