HP C/iX Library Reference Manual (30026-90004)

142 Chapter5
HP C/iX Library Function Descriptions
fcvt
fcvt
Converts a floating-point number to a string.
Syntax
char *fcvt (double
value
, int
ndigit
, int *
decpt
, int *
sign
);
Parameters
value
The floating-point number to be converted to a character string.
ndigit
The number of digits to convert.
decpt
A pointer to an integer to which the position of the decimal point relative
to the beginning of the string is returned.
sign
A pointer to an integer to which a flag indicating the sign of the number is
returned.
Return Values
x A pointer to a character array containing the resulting numeric character
string.
Description
The fcvt function converts
value
to a null-terminated string of
ndigit
digits and returns
a pointer to the string. The resulting numeric string is rounded and left-justified without
leading zeros. The position of the decimal point relative to the beginning of the string is
stored indirectly through
decpt
(negative means to the left of the returned digits). The
decimal point is not included in the returned string. If the sign of the result is negative, the
word pointed to by
sign
is non-zero; otherwise, the word pointed to by
sign
is zero.
This function is identical to ecvt(), except that the correct digit has been rounded for
printf %f (FORTRAN F-format) output of the number of digits specified by
ndigit
.
The fcvt function points to a single static data array whose content is overwritten by each
call.
See Also
ecvt(), gcvt()