NAME

usfnum - format numeric value without an exponent

SYNOPSIS

#include <basic/string.h>
#include <basic/type.h>
#include <basic/generic.h>

int usfnum(s, type, generic, sign, pound,
fill, dollar, hasdot, dot, comma)
char *s, fill;
int type, sign, pound, dollar, hasdot, dot, comma;
union generic generic;

DESCRIPTION

Usfnum formats the numeric value given by type, generic (see generic(inc)) and stores it in the null-terminated string s according to the remaining arguments.  Usfnum returns zero unless the value can not be formatted as specified.  The format is described in printu(io), specifically, the formatting of numeric values without an exponent. 

Sign is an enumerated value which indicates how the sign of the value is to be formatted:

            Sign      Printu sign format
 
0Sign format not specified
1Leading + (plus)
2Trailing - (minus)
3Trailing + (plus)

Pound is the maximum number of positions available for digits including a leading sign, a $ (dollar) and commas, if specified, but excluding a decimal point, if specified.  Fill is the character for padding on the left.  If dollar is set, a $ (dollar) is to be included.  If hasdot is set, a decimal point is to be included and dot is the position before which the decimal point is to be located.  If comma is set, commas are to be included before every third digit. 

The basic conversion is performed via docvt (see numcvt(io)). 

This function supports printu and does not directly implement any BASIC functions. 

SEE ALSO

generic(inc), numcvt(io), printu(io)

DIAGNOSTICS

Usfnum returns one if there is not enough space to format a sign and a $ (dollar), if specified, and the non-fractional part of the number to the left of the indicated location of the decimal point; nevertheless, a valid representation of the value is produced albeit a longer representation than specified. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber