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 non-zero value if the value parameter is
negative, and sets it to 0 otherwise.
The fcvt subroutine functions identically to ecvt, except
that it rounds the correct digit for outputting ndigit
digits in FORTRAN F-format.
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 zeroes. The
string is ready for printing, complete with minus sign,
decimal point, or exponent, as appropriate.
The ecvt, fcvt, and gcvt subroutines represent the fol-
lowing special values that are specified in ANSI/IEEE
standard 754-1985 for binary floating-point arithmetic:
Quiet NaN "QNaN"
Signalling NaN "SNaN"
A&infinity. "INF"
The sign associated with each of these values is stored
into the sign parameter. Note, also, that 0 can be posi-
tive or negative.
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," and "scanf, fscanf, sscanf, NLscanf,
NLfscanf, NLsscanf."