Converts a floating point number to a string.
#include <prdtoa.h> PRStatus PR_dtoa( PRFloat64 d, PRIntn mode, PRIntn ndigits, PRIntn *decpt, PRIntn *sign, char **rve, char *buf, PRSize bufsz);
The function has these parameters:
d
mode
ndigits
decpt
sign
*rve
NULL
this location is set to the address of the end of the result.buf
bufsz
The principle output is the null-terminated string stored in buf
. If rve
is not NULL
, *rve
is set to point to the end of the returned value.
This function converts the specified floating point number to a string, using the method specified by mode
. Possible modes are:
0
d
when read in and rounded to nearest.1
2
max(1, ndigits)
significant digits. This gives a return value similar to that of ecvt
, except that trailing zeros are suppressed.3
ndigits
past the decimal point. This gives a return value similar to that from fcvt
, except that trailing zeros are suppressed, and ndigits
can be negative.4,5,8,9
6-9
all others
Upon return, the buffer specified by buf
and bufsz
contains the converted string. Trailing zeros are suppressed. Sufficient space is allocated to the return value to hold the suppressed trailing zeros.
If the input parameter d
is+Infinity,-Infinity orNAN, *decpt
is set to 9999.