fmoneytoa - format MONEY to ASCII



int fmoneytoa (m, format, dest, len, dec)
char *format;
char *dest;
int len;
int dec;


Fmoneytoa converts the MONEY value m to its ASCII string
representation with format, storing the result in dest: a string
of len bytes. The number of bytes used in the formatted result
is returned.

The parameter m is a MONEY value expressed in the basic unit of
currency (i.e., pennies for U.S.A. values). Fmoneytoa first
converts the value to a string and then formats the number using
the format parameter, inserting the decimal place character at
the appropriate point. This method guarantees that there are no
rounding errors when converting a floating point MONEY value to
its character string representation.

If dec is a zero or positive value, it is taken as a number of
decimal places to be formatted. This number overrides the number
of decimal places in the format string. If the value to be
converted contains fewer than dec decimal places, zeros are
inserted at the end of the number. If the value contains more
decimal places, the value is rounded at dec decimal places.


getfmoney(C-3), moneytoa(C-3)
C/Base Reference Manual Chapter 13, "Formatting Data Values"


If an error occurs, fmoneytoa returns a negative number and the
contents of dest are undefined. The following symbolic error
codes are defined in :

FTOOBIG the formatted result is longer than the
destination length, len

FFORMAT format is empty or contains invalid key