]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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. | |
c13182ef | 19 | .\" |
fea681da MK |
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 1999-06-25 "" "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 | .SH DESCRIPTION | |
60a90ecd MK |
42 | The |
43 | .BR ecvt () | |
44 | function converts \fInumber\fP to a null-terminated | |
fea681da MK |
45 | string of \fIndigits\fP digits (where \fIndigits\fP is reduced to an |
46 | system-specific limit determined by the precision of a double), | |
c13182ef MK |
47 | and returns a pointer to the string. |
48 | The high-order digit is non-zero, unless | |
fea681da | 49 | .I number |
c13182ef MK |
50 | is zero. |
51 | The low order digit is rounded. | |
fea681da MK |
52 | The string itself does not contain a decimal point; however, |
53 | the position of the decimal point relative to the start of the string | |
c13182ef MK |
54 | is stored in *\fIdecpt\fP. |
55 | A negative value for *\fIdecpt\fP means that | |
56 | the decimal point is to the left of the start of the string. | |
57 | If the sign of | |
fea681da | 58 | \fInumber\fP is negative, *\fIsign\fP is set to a non-zero value, otherwise |
c13182ef MK |
59 | it's set to 0. |
60 | If | |
fea681da MK |
61 | .I number |
62 | is zero, it is unspecified whether *\fIdecpt\fP is 0 or 1. | |
63 | .PP | |
60a90ecd MK |
64 | The |
65 | .BR fcvt () | |
66 | function is identical to | |
67 | .BR ecvt (), | |
68 | except that | |
fea681da MK |
69 | \fIndigits\fP specifies the number of digits after the decimal point. |
70 | .SH "RETURN VALUE" | |
60a90ecd MK |
71 | Both the |
72 | .BR ecvt () | |
73 | and | |
74 | .BR fcvt () | |
75 | functions return a pointer to a | |
fea681da | 76 | static string containing the ASCII representation of \fInumber\fP. |
60a90ecd MK |
77 | The static string is overwritten by each call to |
78 | .BR ecvt () | |
79 | or | |
80 | .BR fcvt (). | |
2b2581ee MK |
81 | .SH "CONFORMING TO" |
82 | SVr2; | |
83 | marked as LEGACY in POSIX.1-2001. | |
fea681da | 84 | .SH NOTES |
c13182ef MK |
85 | These functions are obsolete. |
86 | Instead, | |
fb186734 | 87 | .BR sprintf (3) |
fea681da MK |
88 | is recommended. |
89 | Linux libc4 and libc5 specified the type of | |
90 | .I ndigits | |
91 | as | |
92 | .BR size_t . | |
93 | Not all locales use a point as the radix character (`decimal point'). | |
fea681da MK |
94 | .SH "SEE ALSO" |
95 | .BR ecvt_r (3), | |
96 | .BR gcvt (3), | |
97 | .BR qecvt (3), | |
98 | .BR setlocale (3), | |
99 | .BR sprintf (3) |