ECVT(3) NEWLIB ECVT(3)NAME
2.13 `ecvt', `ecvtf', `fcvt', `fcvtf'--double or float to string
SYNOPSIS
#include <stdlib.h>
char *ecvt(double VAL, int CHARS, int *DECPT, int *SGN);
char *ecvtf(float VAL, int CHARS, int *DECPT, int *SGN);
char *fcvt(double VAL, int DECIMALS,
int *DECPT, int *SGN);
char *fcvtf(float VAL, int DECIMALS,
int *DECPT, int *SGN);
DESCRIPTION
`ecvt' and `fcvt' produce (null-terminated) strings of digits represen‐
tating the `double' number VAL. `ecvtf' and `fcvtf' produce the corre‐
sponding character representations of `float' numbers.
(The `stdlib' functions `ecvtbuf' and `fcvtbuf' are reentrant ver‐
sions of `ecvt' and `fcvt'.)
The only difference between `ecvt' and `fcvt' is the interpretation
of the second argument (CHARS or DECIMALS). For `ecvt', the second
argument CHARS specifies the total number of characters to write (which
is also the number of significant digits in the formatted string, since
these two functions write only digits). For `fcvt', the second argu‐
ment DECIMALS specifies the number of characters to write after the
decimal point; all digits for the integer part of VAL are always
included.
Since `ecvt' and `fcvt' write only digits in the output string, they
record the location of the decimal point in `*DECPT', and the sign of
the number in `*SGN'. After formatting a number, `*DECPT' contains the
number of digits to the left of the decimal point. `*SGN' contains `0'
if the number is positive, and `1' if it is negative.
RETURNS
All four functions return a pointer to the new string containing a
character representation of VAL.
PORTABILITY
None of these functions are ANSI C.
Supporting OS subroutines required: `close', `fstat', `isatty',
`lseek', `read', `sbrk', `write'.
SEE ALSOecvt is part of the library. The full documentation for is maintained
as a Texinfo manual. If info and are properly installed at your site,
the command
info
will give you access to the complete manual.
NEWLIB April 2010 ECVT(3)