OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / ecvt.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
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 .\"
32 .TH ECVT 3 2014-08-19 "" "Linux Programmer's Manual"
33 .SH NAME
34 ecvt, 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 );
43 .sp
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .sp
49 .BR ecvt (),
50 .BR fcvt ():
51 .ad l
52 .RS 4
53 .PD 0
54 .TP 4
55 Since glibc 2.12:
56 .nf
57 _SVID_SOURCE ||
58     (_XOPEN_SOURCE\ >=\ 500 ||
59         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
60     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
61 .fi
62 .TP 4
63 Before glibc 2.12:
64 _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
65 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
66 .PD
67 .RE
68 .ad b
69 .SH DESCRIPTION
70 The
71 .BR ecvt ()
72 function converts \fInumber\fP to a null-terminated
73 string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a
74 system-specific limit determined by the precision of a
75 .IR double ),
76 and returns a pointer to the string.
77 The high-order digit is nonzero, unless
78 .I number
79 is zero.
80 The low order digit is rounded.
81 The string itself does not contain a decimal point; however,
82 the position of the decimal point relative to the start of the string
83 is stored in \fI*decpt\fP.
84 A negative value for \fI*decpt\fP means that
85 the decimal point is to the left of the start of the string.
86 If the sign of
87 \fInumber\fP is negative, \fI*sign\fP is set to a nonzero value,
88 otherwise it is set to 0.
89 If
90 .I number
91 is zero, it is unspecified whether \fI*decpt\fP is 0 or 1.
92 .PP
93 The
94 .BR fcvt ()
95 function is identical to
96 .BR ecvt (),
97 except that
98 \fIndigits\fP specifies the number of digits after the decimal point.
99 .SH RETURN VALUE
100 Both the
101 .BR ecvt ()
102 and
103 .BR fcvt ()
104 functions return a pointer to a
105 static string containing the ASCII representation of \fInumber\fP.
106 The static string is overwritten by each call to
107 .BR ecvt ()
108 or
109 .BR fcvt ().
110 .SH ATTRIBUTES
111 .SS Multithreading (see pthreads(7))
112 The
113 .BR ecvt ()
114 and
115 .BR fcvt ()
116 functions are not thread-safe.
117 .SH CONFORMING TO
118 SVr2;
119 marked as LEGACY in POSIX.1-2001.
120 POSIX.1-2008 removes the specifications of
121 .BR ecvt ()
122 and
123 .BR fcvt (),
124 recommending the use of
125 .BR sprintf (3)
126 instead (though
127 .BR snprintf (3)
128 may be preferable).
129 .SH NOTES
130 .\" Linux libc4 and libc5 specified the type of
131 .\" .I ndigits
132 .\" as
133 .\" .IR size_t .
134 Not all locales use a point as the radix character ("decimal point").
135 .SH SEE ALSO
136 .BR ecvt_r (3),
137 .BR gcvt (3),
138 .BR qecvt (3),
139 .BR setlocale (3),
140 .BR sprintf (3)
141 .SH COLOPHON
142 This page is part of release 3.79 of the Linux
143 .I man-pages
144 project.
145 A description of the project,
146 information about reporting bugs,
147 and the latest version of this page,
148 can be found at
149 \%http://www.kernel.org/doc/man\-pages/.