fcvtbuf---double or float to string
#include <stdio.h> char *ecvtbuf(double val, int chars, int *decpt, int *sgn, char *buf); char *fcvtbuf(double val, int decimals, int *decpt, int *sgn, char *buf);
fcvtbuf produce (null-terminated) strings
of digits representating the
double number val.
The only difference between
fcvtbuf is the
interpretation of the second argument (chars or
ecvtbuf, 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
the second argument decimals specifies the number of
characters to write after the decimal point; all digits for
the integer part of val are always included.
fcvtbuf write only digits in the
output string, they record the location of the decimal point
*decpt, and the sign of the number in
After formatting a number,
*decpt contains the number
of digits to the left of the decimal point.
0 if the number is positive, and
1 if it is
negative. For both functions, you supply a pointer buf to
an area of memory to hold the converted string.
Both functions return a pointer to buf, the string containing a character representation of val.
Neither function is ANSI C.
Supporting OS subroutines required:
Go to the first, previous, next, last section, table of contents.