]>
Commit | Line | Data |
---|---|---|
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 | .\" | |
97986708 | 32 | .TH ECVT 3 2016-03-15 "" "Linux Programmer's Manual" |
fea681da MK |
33 | .SH NAME |
34 | ecvt, fcvt \- convert a floating-point number to a string | |
35 | .SH SYNOPSIS | |
36 | .B #include <stdlib.h> | |
68e4db0a | 37 | .PP |
fea681da MK |
38 | .BI "char *ecvt(double " number ", int " ndigits ", int *" decpt , |
39 | .BI "int *" sign ); | |
68e4db0a | 40 | .PP |
fea681da MK |
41 | .BI "char *fcvt(double " number ", int " ndigits ", int *" decpt , |
42 | .BI "int *" sign ); | |
68e4db0a | 43 | .PP |
cc4615cc MK |
44 | .in -4n |
45 | Feature Test Macro Requirements for glibc (see | |
46 | .BR feature_test_macros (7)): | |
47 | .in | |
68e4db0a | 48 | .PP |
cc4615cc MK |
49 | .BR ecvt (), |
50 | .BR fcvt (): | |
4943de06 MK |
51 | .ad l |
52 | .RS 4 | |
53 | .PD 0 | |
54 | .TP 4 | |
55 | Since glibc 2.12: | |
56 | .nf | |
2b1b0424 MK |
57 | (_XOPEN_SOURCE\ >=\ 500) ! (_POSIX_C_SOURCE\ >=\ 200112L) |
58 | || /* Glibc since 2.19: */ _DEFAULT_SOURCE | |
59 | || /* Glibc versions <= 2.19: */ _SVID_SOURCE | |
4943de06 MK |
60 | .fi |
61 | .TP 4 | |
62 | Before glibc 2.12: | |
cf7fa0a1 MK |
63 | _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 |
64 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED | |
4943de06 MK |
65 | .PD |
66 | .RE | |
67 | .ad b | |
fea681da | 68 | .SH DESCRIPTION |
60a90ecd MK |
69 | The |
70 | .BR ecvt () | |
71 | function converts \fInumber\fP to a null-terminated | |
3c5e62b6 | 72 | string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a |
6d275e3c MK |
73 | system-specific limit determined by the precision of a |
74 | .IR double ), | |
c13182ef | 75 | and returns a pointer to the string. |
c7094399 | 76 | The high-order digit is nonzero, unless |
fea681da | 77 | .I number |
c13182ef MK |
78 | is zero. |
79 | The low order digit is rounded. | |
fea681da MK |
80 | The string itself does not contain a decimal point; however, |
81 | the position of the decimal point relative to the start of the string | |
8c1a40ca MK |
82 | is stored in \fI*decpt\fP. |
83 | A negative value for \fI*decpt\fP means that | |
c13182ef MK |
84 | the decimal point is to the left of the start of the string. |
85 | If the sign of | |
c7094399 | 86 | \fInumber\fP is negative, \fI*sign\fP is set to a nonzero value, |
3758f6da | 87 | otherwise it is set to 0. |
c13182ef | 88 | If |
fea681da | 89 | .I number |
8c1a40ca | 90 | is zero, it is unspecified whether \fI*decpt\fP is 0 or 1. |
fea681da | 91 | .PP |
60a90ecd MK |
92 | The |
93 | .BR fcvt () | |
94 | function is identical to | |
95 | .BR ecvt (), | |
96 | except that | |
fea681da | 97 | \fIndigits\fP specifies the number of digits after the decimal point. |
47297adb | 98 | .SH RETURN VALUE |
60a90ecd MK |
99 | Both the |
100 | .BR ecvt () | |
101 | and | |
102 | .BR fcvt () | |
103 | functions return a pointer to a | |
fea681da | 104 | static string containing the ASCII representation of \fInumber\fP. |
60a90ecd MK |
105 | The static string is overwritten by each call to |
106 | .BR ecvt () | |
107 | or | |
108 | .BR fcvt (). | |
ff6bff8a | 109 | .SH ATTRIBUTES |
e63161a4 MK |
110 | For an explanation of the terms used in this section, see |
111 | .BR attributes (7). | |
112 | .TS | |
113 | allbox; | |
114 | lb lb lb | |
115 | l l l. | |
116 | Interface Attribute Value | |
117 | T{ | |
b972e06e MS |
118 | .BR ecvt () |
119 | T} Thread safety MT-Unsafe race:ecvt | |
120 | T{ | |
ff6bff8a | 121 | .BR fcvt () |
b972e06e | 122 | T} Thread safety MT-Unsafe race:fcvt |
e63161a4 | 123 | .TE |
47297adb | 124 | .SH CONFORMING TO |
2b2581ee MK |
125 | SVr2; |
126 | marked as LEGACY in POSIX.1-2001. | |
2ce94173 MK |
127 | POSIX.1-2008 removes the specifications of |
128 | .BR ecvt () | |
129 | and | |
5a466811 MK |
130 | .BR fcvt (), |
131 | recommending the use of | |
fb186734 | 132 | .BR sprintf (3) |
5a466811 MK |
133 | instead (though |
134 | .BR snprintf (3) | |
135 | may be preferable). | |
136 | .SH NOTES | |
d9737a3c MK |
137 | .\" Linux libc4 and libc5 specified the type of |
138 | .\" .I ndigits | |
139 | .\" as | |
140 | .\" .IR size_t . | |
2d986c92 | 141 | Not all locales use a point as the radix character ("decimal point"). |
47297adb | 142 | .SH SEE ALSO |
fea681da MK |
143 | .BR ecvt_r (3), |
144 | .BR gcvt (3), | |
145 | .BR qecvt (3), | |
146 | .BR setlocale (3), | |
147 | .BR sprintf (3) |