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               _SVID_SOURCE ||
20                   (_XOPEN_SOURCE >= 500 ||
21                       _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
22                   !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
23           Before glibc 2.12:
24               _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
25               _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
26

DESCRIPTION

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

RETURN VALUE

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

ATTRIBUTES

49   Multithreading (see pthreads(7))
50       The ecvt() and fcvt() functions are not thread-safe.
51

CONFORMING TO

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

NOTES

58       Linux libc4 and libc5 specified the type of ndigits as size_t.  Not all
59       locales use a point as the radix character ("decimal point").
60

SEE ALSO

62       ecvt_r(3), gcvt(3), qecvt(3), setlocale(3), sprintf(3)
63

COLOPHON

65       This page is part of release 3.53 of the Linux  man-pages  project.   A
66       description  of  the project, and information about reporting bugs, can
67       be found at http://www.kernel.org/doc/man-pages/.
68
69
70
71                                  2013-07-04                           ECVT(3)
Impressum