ECVT(3,L) AIX Technical Reference ECVT(3,L)
-------------------------------------------------------------------------------
ecvt, fcvt, gcvt
PURPOSE
Converts a floating-point number to a string.
LIBRARY
Standard C Library (libc.a)
SYNTAX
char *ecvt (value, ndigit, decpt, sign) char *gcvt (value, ndigit, buf)
double value; double value;
int ndigit, *decpt, *sign; int ndigit;
char *buf;
char *fcvt (value, ndigit, decpt, sign)
double value;
int ndigit, *decpt, *sign;
DESCRIPTION
The ecvt, fcvt, and gcvt subroutines convert floating-point numbers to strings.
The ecvt subroutine converts the value parameter to a null-terminated string
and returns a pointer to it. The ndigit parameter specifies the number of
digits in the string. The low-order digit is rounded. ecvt sets the int
pointed to by the decpt parameter to the position of the decimal point relative
to the beginning of the string. (A negative number means the decimal point is
to the left of the digits given in the string). The decimal point itself is
not included in the string. The ecvt subroutine also sets the int pointed to
by the sign parameter to a nonzero value if the value parameter is negative and
sets it to 0 otherwise.
The fcvt subroutine functions identically to ecvt, except that ndigit produces
the number of digits to the right of the decimal point only; if the number is
=>17, there may be truncation or imprecision.
The gcvt subroutine converts the value parameter to a null-terminated string,
stores it in the array pointed to by the buf parameter, and then returns buf.
gcvt attempts to produce a string of ndigit significant digits in FORTRAN
F-format. If this is not possible, then E-format is used. gcvt suppresses
trailing zeros. The string is ready for printing, complete with minus sign,
decimal point, or exponent, as appropriate.
Processed November 7, 1990 ECVT(3,L) 1
ECVT(3,L) AIX Technical Reference ECVT(3,L)
The ecvt, fcvt, and gcvt subroutines represent the following special values
that are specified in ANSI/IEEE standard 754-1985 for binary floating-point
arithmetic:
Quiet NaN "QNaN"
Signalling NaN "SNaN"
+/-infinity "INF"
The sign associated with each of these values is stored into the sign
parameter; zero can also be positive or negative.
Note: In the F-format ndigit is the number of digits desired after the decimal
point. Very large numbers will produce a very long string of digits
before the decimal point and then ndigit digits after the decimal point.
Generally it is better to use gcvt or ecvt for large numbers.
Warning: All three subroutines store the strings in a static area of memory
whose contents are overwritten each time one of the subroutines is called.
RELATED INFORMATION
In this book: "a64l, l64a," "frexp, ldexp, modf," "printf, fprintf, sprintf,
NLprintf, NLfprintf, NLsprintf, wsprintf," and "scanf, fscanf, sscanf, NLscanf,
NLfscanf, NLsscanf, wsscanf."
Processed November 7, 1990 ECVT(3,L) 2