2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 19:40:39 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified Fri Jun 25 12:10:47 1999 by Andries Brouwer (aeb@cwi.nl)
13 .TH ecvt 3 (date) "Linux man-pages (unreleased)"
15 ecvt, fcvt \- convert a floating-point number to a string
18 .RI ( libc ", " \-lc )
21 .B #include <stdlib.h>
23 .BI "[[deprecated]] char *ecvt(double " number ", int " ndigits ,
24 .BI " int *restrict " decpt ", int *restrict " sign );
25 .BI "[[deprecated]] char *fcvt(double " number ", int " ndigits ,
26 .BI " int *restrict " decpt ", int *restrict " sign );
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
38 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200809L))
39 || /* glibc >= 2.20 */ _DEFAULT_SOURCE
40 || /* glibc <= 2.19 */ _SVID_SOURCE
41 glibc 2.12 to glibc 2.16:
42 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200112L))
45 _SVID_SOURCE || _XOPEN_SOURCE >= 500
46 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
51 function converts \fInumber\fP to a null-terminated
52 string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a
53 system-specific limit determined by the precision of a
55 and returns a pointer to the string.
56 The high-order digit is nonzero, unless
59 The low order digit is rounded.
60 The string itself does not contain a decimal point; however,
61 the position of the decimal point relative to the start of the string
62 is stored in \fI*decpt\fP.
63 A negative value for \fI*decpt\fP means that
64 the decimal point is to the left of the start of the string.
66 \fInumber\fP is negative, \fI*sign\fP is set to a nonzero value,
67 otherwise it is set to 0.
70 is zero, it is unspecified whether \fI*decpt\fP is 0 or 1.
74 function is identical to
77 \fIndigits\fP specifies the number of digits after the decimal point.
83 functions return a pointer to a
84 static string containing the ASCII representation of \fInumber\fP.
85 The static string is overwritten by each call to
90 For an explanation of the terms used in this section, see
96 Interface Attribute Value
101 T} Thread safety MT-Unsafe race:ecvt
106 T} Thread safety MT-Unsafe race:fcvt
112 marked as LEGACY in POSIX.1-2001.
113 POSIX.1-2008 removes the specifications of
117 recommending the use of
123 .\" Linux libc4 and libc5 specified the type of
127 Not all locales use a point as the radix character ("decimal point").