Unleashed v1.4
[unleashed.git] / share / man / man3c / ecvt.3c
blobb74c05e3dcb7dd13ed8c8a4ee0ea4f4ff35cb763
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited,  All Rights Reserved.
45 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH ECVT 3C "May 18, 2004"
48 .SH NAME
49 ecvt, fcvt, gcvt \- convert floating-point number to string
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <stdlib.h>
55 \fBchar *\fR\fBecvt\fR(\fBdouble\fR \fIvalue\fR, \fBint\fR \fIndigit\fR, \fBint *restrict\fR \fIdecpt\fR, \fBint *restrict\fR \fIsign\fR);
56 .fi
58 .LP
59 .nf
60 \fBchar *\fR\fBfcvt\fR(\fBdouble\fR \fIvalue\fR, \fBint\fR \fIndigit\fR, \fBint *restrict\fR \fIdecpt\fR, \fBint *restrict\fR \fIsign\fR);
61 .fi
63 .LP
64 .nf
65 \fBchar *\fR\fBgcvt\fR(\fBdouble\fR \fIvalue\fR, \fBint\fR \fIndigit\fR, \fBchar *\fR\fIbuf\fR);
66 .fi
68 .SH DESCRIPTION
69 .sp
70 .LP
71 The \fBecvt()\fR, \fBfcvt()\fR and \fBgcvt()\fR functions convert
72 floating-point numbers to null-terminated strings.
73 .SS "\fBecvt()\fR"
74 .sp
75 .LP
76 The \fBecvt()\fR function converts \fIvalue\fR to a null-terminated string of
77 \fIndigit\fR digits (where \fIndigit\fR is reduced to an unspecified limit
78 determined by the precision of a \fBdouble\fR) and returns a pointer to the
79 string.  The high-order digit is non-zero, unless the value is 0.  The
80 low-order digit is rounded.  The position of the radix character relative to
81 the beginning of the string is stored in the integer pointed to by \fIdecpt\fR
82 (negative means to the left of the returned digits). The radix character is not
83 included in the returned string. If the sign of the result is negative, the
84 integer pointed to by \fIsign\fR is non-zero, otherwise it is 0.
85 .sp
86 .LP
87 If the converted value is out of range or is not representable, the contents of
88 the returned string are unspecified.
89 .SS "\fBfcvt()\fR"
90 .sp
91 .LP
92 The \fBfcvt()\fR function is identical to \fBecvt()\fR except that \fIndigit\fR
93 specifies the number of digits desired after the radix point.  The total number
94 of digits in the result string is restricted to an unspecified limit as
95 determined by the precision of a \fBdouble\fR.
96 .SS "\fBgcvt()\fR"
97 .sp
98 .LP
99 The \fBgcvt()\fR function converts \fIvalue\fR to a null-terminated string
100 (similar to that of the \fB%g\fR format of \fBprintf\fR(3C)) in the array
101 pointed to by \fIbuf\fR and returns \fIbuf\fR. It produces \fIndigit\fR
102 significant digits (limited to an unspecified value determined by the precision
103 of a \fBdouble\fR) in \fB%f\fR if possible, or \fB%e\fR (scientific notation)
104 otherwise.  A minus sign is included in the returned string if \fIvalue\fR is
105 less than 0.  A radix character is included in the returned string if
106 \fIvalue\fR is not a whole number.  Trailing zeros are suppressed where
107 \fIvalue\fR is not a whole number.  The radix character is determined by the
108 current locale. If \fBsetlocale\fR(3C) has not been called successfully, the
109 default locale, POSIX, is used.  The default locale specifies a period
110 (\fB\&.\fR) as the radix character.  The \fBLC_NUMERIC\fR category determines
111 the value of the radix character within the current locale.
112 .SH RETURN VALUES
115 The \fBecvt()\fR and \fBfcvt()\fR functions return a pointer to a
116 null-terminated string of digits.
119 The \fBgcvt()\fR function returns \fIbuf\fR.
120 .SH ERRORS
123 No errors are defined.
124 .SH USAGE
127 The return values from \fBecvt()\fR and \fBfcvt()\fR might point to
128 thread-specific data that can be overwritten by subsequent calls to these
129 functions by the same thread.
132 For portability to implementations conforming to earlier versions of Solaris,
133 \fBsprintf\fR(3C) is preferred over this function.
134 .SH ATTRIBUTES
137 See \fBattributes\fR(5) for descriptions of the following attributes:
142 box;
143 c | c
144 l | l .
145 ATTRIBUTE TYPE  ATTRIBUTE VALUE
147 Interface Stability     Standard
149 MT-Level        Safe
152 .SH SEE ALSO
155 \fBprintf\fR(3C), \fBsetlocale\fR(3C), \fBsprintf\fR(3C), \fBattributes\fR(5),
156 \fBstandards\fR(5)