FMONEYTOA C-3

NAME

fmoneytoa - format MONEY to ASCII

SYNOPSIS

#include <cbase/dtypes.h>

int fmoneytoa (m, format, dest, len, dec)

MONEY m;

char *format;

char *dest;

int len;

int dec;

DESCRIPTION

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.

SEE ALSO

getfmoney(C-3), moneytoa(C-3)

C/Base Reference Manual Chapter 13, "Formatting Data Values"

DIAGNOSTICS

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

FTOOBIG the formatted result is longer than the destination length,

len

FFORMAT format is empty or contains invalid key letters