OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man3 / ecvt.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 19:40:39 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Fri Jun 25 12:10:47 1999 by Andries Brouwer (aeb@cwi.nl)
29 .\"
30 .TH ECVT 3 2009-03-15 "" "Linux Programmer's Manual"
31 .SH NAME
32 ecvt, fcvt \- convert a floating-point number to a string
33 .SH SYNOPSIS
34 .B #include <stdlib.h>
35 .sp
36 .BI "char *ecvt(double " number ", int " ndigits ", int *" decpt ,
37 .BI "int *" sign );
38 .sp
39 .BI "char *fcvt(double " number ", int " ndigits ", int *" decpt ,
40 .BI "int *" sign );
41 .sp
42 .in -4n
43 Feature Test Macro Requirements for glibc (see
44 .BR feature_test_macros (7)):
45 .in
46 .sp
47 .BR ecvt (),
48 .BR fcvt ():
49 _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
50 .SH DESCRIPTION
51 The
52 .BR ecvt ()
53 function converts \fInumber\fP to a null-terminated
54 string of \fIndigits\fP digits (where \fIndigits\fP is reduced to a
55 system-specific limit determined by the precision of a
56 .IR double ),
57 and returns a pointer to the string.
58 The high-order digit is nonzero, unless
59 .I number
60 is zero.
61 The low order digit is rounded.
62 The string itself does not contain a decimal point; however,
63 the position of the decimal point relative to the start of the string
64 is stored in \fI*decpt\fP.
65 A negative value for \fI*decpt\fP means that
66 the decimal point is to the left of the start of the string.
67 If the sign of
68 \fInumber\fP is negative, \fI*sign\fP is set to a nonzero value,
69 otherwise it is set to 0.
70 If
71 .I number
72 is zero, it is unspecified whether \fI*decpt\fP is 0 or 1.
73 .PP
74 The
75 .BR fcvt ()
76 function is identical to
77 .BR ecvt (),
78 except that
79 \fIndigits\fP specifies the number of digits after the decimal point.
80 .SH "RETURN VALUE"
81 Both the
82 .BR ecvt ()
83 and
84 .BR fcvt ()
85 functions return a pointer to a
86 static string containing the ASCII representation of \fInumber\fP.
87 The static string is overwritten by each call to
88 .BR ecvt ()
89 or
90 .BR fcvt ().
91 .SH "CONFORMING TO"
92 SVr2;
93 marked as LEGACY in POSIX.1-2001.
94 POSIX.1-2008 removes the specifications of
95 .BR ecvt ()
96 and
97 .BR fcvt (),
98 recommending the use of
99 .BR sprintf (3)
100 instead (though
101 .BR snprintf (3)
102 may be preferable).
103 .SH NOTES
104 Linux libc4 and libc5 specified the type of
105 .I ndigits
106 as
107 .IR size_t .
108 Not all locales use a point as the radix character ("decimal point").
109 .SH "SEE ALSO"
110 .BR ecvt_r (3),
111 .BR gcvt (3),
112 .BR qecvt (3),
113 .BR setlocale (3),
114 .BR sprintf (3)