104 const int false = 0;
const int true = !
false;
106 static mnyfmt_long TENPOW[6+1] = { 1,10,100,1000,10000,100000,1000000 };
107 if ( CE>(-1+
sizeof(TENPOW)/
sizeof(*TENPOW)) ) {
return 0; }
109 char *pDec, *pSign, *p;
110 unsigned nDigits, nFrac;
118 typedef int check_digit_size[ ( (2<=
sizeof(CE)) ? 1 : -1 ) ];
120 if (!( fmtstr) ) {
return 0; }
128 if ( *pDec==dec ) {
break; }
131 if ( pDec==fmtstr || nNines == 0 ) {
return 0; }
134 if ( 0 <= moneyval ) { isPositive =
true;}
137 moneyval = -moneyval;
138 if ( moneyval<0 ) {
return 0; }
140 nFrac = ( moneyval % TENPOW[CE] );
141 moneyval = ( moneyval / TENPOW[CE] );
151 digit[nDigits] = moneyval % 10;
154 }
while ( moneyval!=0 );
159 if ( nNines < nDigits ) {
return 0; }
162 if ( nNines < nDigits+1 ) {
return 0; }
168 for ( i=0; i<nNines; ++i ) {
174 else if ( ! isPositive ) {
191 for ( i=0; i<CE; ++i ) {
192 digit[i] = nFrac % 10;
210 else if ( *pDec==0 ) {
221 for ( i=0; i<CE; ++i ) {
222 digit[i] = nFrac % 10;
233 if ( i==0 ) {
break; }
240 p = ( (*pDec==0) ? pDec : pDec+1 );
246 if ( i!=0 ) {
return 0; };
Header file for mnyfmt().
char * mnyfmt(char *fmtstr, char dec, mnyfmt_long moneyval, unsigned CE)
Formats and stores in fmtstr the money amount.
#define mnyfmt_format_char
Formatting character for mnyfmt().