]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ecvt.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / ecvt.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
5.\" References consulted:
6.\" Linux libc source code
7.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8.\" 386BSD man pages
9.\" Modified Sat Jul 24 19:40:39 1993 by Rik Faith (faith@cs.unc.edu)
10.\" Modified Fri Jun 25 12:10:47 1999 by Andries Brouwer (aeb@cwi.nl)
11.\"
45186a5d 12.TH ECVT 3 2021-03-22 "Linux man-pages (unreleased)"
fea681da
MK
13.SH NAME
14ecvt, fcvt \- convert a floating-point number to a string
b813014f
AC
15.SH LIBRARY
16Standard C library
17.RI ( libc ", " \-lc )
fea681da 18.SH SYNOPSIS
15d65653 19.nf
fea681da 20.B #include <stdlib.h>
68e4db0a 21.PP
017103fa
AC
22.BI "char *ecvt(double " number ", int " ndigits ", int *restrict " decpt ,
23.BI " int *restrict " sign );
24.BI "char *fcvt(double " number ", int " ndigits ", int *restrict " decpt ,
25.BI " int *restrict " sign );
15d65653 26.fi
68e4db0a 27.PP
d39ad78f 28.RS -4
cc4615cc
MK
29Feature Test Macro Requirements for glibc (see
30.BR feature_test_macros (7)):
d39ad78f 31.RE
68e4db0a 32.PP
cc4615cc
MK
33.BR ecvt (),
34.BR fcvt ():
4943de06 35.nf
2bb10332
MK
36 Since glibc 2.17
37 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200809L))
38 || /* Glibc >= 2.20 */ _DEFAULT_SOURCE
39 || /* Glibc <= 2.19 */ _SVID_SOURCE
40 Glibc versions 2.12 to 2.16:
41 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200112L))
42 || _SVID_SOURCE
43 Before glibc 2.12:
5c10d2c5 44 _SVID_SOURCE || _XOPEN_SOURCE >= 500
2bb10332 45.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
4943de06 46.fi
fea681da 47.SH DESCRIPTION
60a90ecd
MK
48The
49.BR ecvt ()
50function converts \fInumber\fP to a null-terminated
3c5e62b6 51string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a
6d275e3c
MK
52system-specific limit determined by the precision of a
53.IR double ),
c13182ef 54and returns a pointer to the string.
c7094399 55The high-order digit is nonzero, unless
fea681da 56.I number
c13182ef
MK
57is zero.
58The low order digit is rounded.
fea681da
MK
59The string itself does not contain a decimal point; however,
60the position of the decimal point relative to the start of the string
8c1a40ca
MK
61is stored in \fI*decpt\fP.
62A negative value for \fI*decpt\fP means that
c13182ef
MK
63the decimal point is to the left of the start of the string.
64If the sign of
c7094399 65\fInumber\fP is negative, \fI*sign\fP is set to a nonzero value,
3758f6da 66otherwise it is set to 0.
c13182ef 67If
fea681da 68.I number
8c1a40ca 69is zero, it is unspecified whether \fI*decpt\fP is 0 or 1.
fea681da 70.PP
60a90ecd
MK
71The
72.BR fcvt ()
73function is identical to
74.BR ecvt (),
75except that
fea681da 76\fIndigits\fP specifies the number of digits after the decimal point.
47297adb 77.SH RETURN VALUE
60a90ecd
MK
78Both the
79.BR ecvt ()
80and
81.BR fcvt ()
82functions return a pointer to a
fea681da 83static string containing the ASCII representation of \fInumber\fP.
60a90ecd
MK
84The static string is overwritten by each call to
85.BR ecvt ()
86or
87.BR fcvt ().
ff6bff8a 88.SH ATTRIBUTES
e63161a4
MK
89For an explanation of the terms used in this section, see
90.BR attributes (7).
c466875e
MK
91.ad l
92.nh
e63161a4
MK
93.TS
94allbox;
c466875e 95lbx lb lb
e63161a4
MK
96l l l.
97Interface Attribute Value
98T{
b972e06e
MS
99.BR ecvt ()
100T} Thread safety MT-Unsafe race:ecvt
101T{
ff6bff8a 102.BR fcvt ()
b972e06e 103T} Thread safety MT-Unsafe race:fcvt
e63161a4 104.TE
c466875e
MK
105.hy
106.ad
107.sp 1
3113c7f3 108.SH STANDARDS
2b2581ee
MK
109SVr2;
110marked as LEGACY in POSIX.1-2001.
2ce94173
MK
111POSIX.1-2008 removes the specifications of
112.BR ecvt ()
113and
5a466811
MK
114.BR fcvt (),
115recommending the use of
fb186734 116.BR sprintf (3)
5a466811
MK
117instead (though
118.BR snprintf (3)
119may be preferable).
120.SH NOTES
d9737a3c
MK
121.\" Linux libc4 and libc5 specified the type of
122.\" .I ndigits
123.\" as
124.\" .IR size_t .
2d986c92 125Not all locales use a point as the radix character ("decimal point").
47297adb 126.SH SEE ALSO
fea681da
MK
127.BR ecvt_r (3),
128.BR gcvt (3),
129.BR qecvt (3),
130.BR setlocale (3),
131.BR sprintf (3)