]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ecvt.3
fenv.3: tfix in thread-safety information
[thirdparty/man-pages.git] / man3 / ecvt.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
29.\" Modified Sat Jul 24 19:40:39 1993 by Rik Faith (faith@cs.unc.edu)
30.\" Modified Fri Jun 25 12:10:47 1999 by Andries Brouwer (aeb@cwi.nl)
31.\"
8980a500 32.TH ECVT 3 2014-08-19 "" "Linux Programmer's Manual"
fea681da
MK
33.SH NAME
34ecvt, fcvt \- convert a floating-point number to a string
35.SH SYNOPSIS
36.B #include <stdlib.h>
37.sp
38.BI "char *ecvt(double " number ", int " ndigits ", int *" decpt ,
39.BI "int *" sign );
40.sp
41.BI "char *fcvt(double " number ", int " ndigits ", int *" decpt ,
42.BI "int *" sign );
cc4615cc
MK
43.sp
44.in -4n
45Feature Test Macro Requirements for glibc (see
46.BR feature_test_macros (7)):
47.in
48.sp
49.BR ecvt (),
50.BR fcvt ():
4943de06
MK
51.ad l
52.RS 4
53.PD 0
54.TP 4
55Since glibc 2.12:
56.nf
57_SVID_SOURCE ||
98dbe7af 58 (_XOPEN_SOURCE\ >=\ 500 ||
7b072c4d 59 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
98dbe7af 60 !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
4943de06
MK
61.fi
62.TP 4
63Before glibc 2.12:
98dbe7af
MK
64_SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
65_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
4943de06
MK
66.PD
67.RE
68.ad b
fea681da 69.SH DESCRIPTION
60a90ecd
MK
70The
71.BR ecvt ()
72function converts \fInumber\fP to a null-terminated
3c5e62b6 73string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a
6d275e3c
MK
74system-specific limit determined by the precision of a
75.IR double ),
c13182ef 76and returns a pointer to the string.
c7094399 77The high-order digit is nonzero, unless
fea681da 78.I number
c13182ef
MK
79is zero.
80The low order digit is rounded.
fea681da
MK
81The string itself does not contain a decimal point; however,
82the position of the decimal point relative to the start of the string
8c1a40ca
MK
83is stored in \fI*decpt\fP.
84A negative value for \fI*decpt\fP means that
c13182ef
MK
85the decimal point is to the left of the start of the string.
86If the sign of
c7094399 87\fInumber\fP is negative, \fI*sign\fP is set to a nonzero value,
3758f6da 88otherwise it is set to 0.
c13182ef 89If
fea681da 90.I number
8c1a40ca 91is zero, it is unspecified whether \fI*decpt\fP is 0 or 1.
fea681da 92.PP
60a90ecd
MK
93The
94.BR fcvt ()
95function is identical to
96.BR ecvt (),
97except that
fea681da 98\fIndigits\fP specifies the number of digits after the decimal point.
47297adb 99.SH RETURN VALUE
60a90ecd
MK
100Both the
101.BR ecvt ()
102and
103.BR fcvt ()
104functions return a pointer to a
fea681da 105static string containing the ASCII representation of \fInumber\fP.
60a90ecd
MK
106The static string is overwritten by each call to
107.BR ecvt ()
108or
109.BR fcvt ().
ff6bff8a 110.SH ATTRIBUTES
e63161a4
MK
111For an explanation of the terms used in this section, see
112.BR attributes (7).
113.TS
114allbox;
115lb lb lb
116l l l.
117Interface Attribute Value
118T{
119.BR ecvt (),
ff6bff8a 120.BR fcvt ()
e63161a4
MK
121T} Thread safety MT-Unsafe
122.TE
47297adb 123.SH CONFORMING TO
2b2581ee
MK
124SVr2;
125marked as LEGACY in POSIX.1-2001.
2ce94173
MK
126POSIX.1-2008 removes the specifications of
127.BR ecvt ()
128and
5a466811
MK
129.BR fcvt (),
130recommending the use of
fb186734 131.BR sprintf (3)
5a466811
MK
132instead (though
133.BR snprintf (3)
134may be preferable).
135.SH NOTES
d9737a3c
MK
136.\" Linux libc4 and libc5 specified the type of
137.\" .I ndigits
138.\" as
139.\" .IR size_t .
2d986c92 140Not all locales use a point as the radix character ("decimal point").
47297adb 141.SH SEE ALSO
fea681da
MK
142.BR ecvt_r (3),
143.BR gcvt (3),
144.BR qecvt (3),
145.BR setlocale (3),
146.BR sprintf (3)