1 .\" $OpenBSD: ecvt.3,v 1.8 2007/05/31 19:19:31 jmc Exp $
3 .\" Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .\" Sponsored in part by the Defense Advanced Research Projects
18 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
19 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
21 .Dd $Mdocdate: May 31 2007 $
32 .Fd #include <stdlib.h>
34 .Fn ecvt "double value" "int ndigit" "int *decpt" "int *sign"
36 .Fn fcvt "double value" "int ndigit" "int *decpt" "int *sign"
38 .Fn gcvt "double value" "int ndigit" "char *buf"
41 These functions are provided for compatibility with legacy code.
42 New code should use the
44 function for improved safety and portability.
52 functions convert the double precision floating-point number
62 to a NUL-terminated string of exactly
64 digits and returns a pointer to that string.
65 The result is padded with zeroes from left to right as needed.
66 There are no leading zeroes unless
69 The least significant digit is rounded in an implementation-dependent manner.
70 The position of the decimal point relative to the beginning of the string
73 A negative value indicates that the decimal point is located
74 to the left of the returned digits (this occurs when there is no
75 whole number component to
79 is zero, it is unspecified whether the integer pointed to by
82 The decimal point itself is not included in the returned string.
83 If the sign of the result is negative, the integer pointed to by
85 is non-zero; otherwise, it is 0.
87 If the converted value is out of range or is not representable,
88 the contents of the returned string are unspecified.
92 function is identical to
94 with the exception that
96 specifies the number of digits after the decimal point (zero-padded as
103 to a NUL-terminated string similar to the %g
105 format specifier and stores the result in
109 significant digits similar to the %f
111 format specifier where possible.
114 does allow sufficient precision, the result is stored in
115 exponential notation similar to the %e
122 will be prefixed with a minus sign.
123 A decimal point is included in the returned string if
125 is not a whole number.
139 functions return a NUL-terminated string representation of
146 functions return a pointer to internal storage space that will be
147 overwritten by subsequent calls to either function.
149 The maximum possible precision of the return value is limited by the
150 precision of a double and may not be the same on all architectures.
154 function is preferred over these functions for new code.