mnyfmt.c: Format money or currency amounts
Macros | Functions
str2mnyCE.c File Reference

Implementation for str2mnyCE(). More...

#include "mnyfmt.h"

Go to the source code of this file.

Macros

#define isdigit(ch)   ('0'<=(char)(ch) && (char)(ch)<='9')
 
#define remove_isdigit
 

Functions

mnyfmt_long str2mnyCE (const char *amount, char dec, unsigned CE)
 Returns an integer value that corresponds to 'amount', scaled 10^CE digits. More...
 

Detailed Description

Implementation for str2mnyCE().

Author
Adolfo Di Mare adolf.nosp@m.o@di.nosp@m.-mare.nosp@m..com
Date
2011

Definition in file str2mnyCE.c.

Macro Definition Documentation

#define isdigit (   ch)    ('0'<=(char)(ch) && (char)(ch)<='9')
#define remove_isdigit

Function Documentation

mnyfmt_long str2mnyCE ( const char *  amount,
char  dec,
unsigned  CE 
)

Returns an integer value that corresponds to 'amount', scaled 10^CE digits.

  • For " -102,455.87" returns '-102_455_8700' when CE==4 && dec=='.'.
  • For " -102,455.07" returns '-102_455_07' when CE==2 && dec=='.'.
  • For " -102,455.87" returns '-102_455' when CE==0 && dec=='.'.
  • The decimal separator is 'dec'.
  • CE is the 'currency exponent'.
  • Requires 'CE<=6' <–> scale up to 10^6 <–> 6 decimal digits.
1 {{ // test::str2mnyCE()
1  assertTrue( -1024550700 == str2mnyCE(" -102,455.07", '.', 4) );
2  assertTrue( -102455070 == str2mnyCE(" -102,455.07", '.', 3) );
3  assertTrue( -10245507 == str2mnyCE(" -102,455.07", '.', 2) );
4  assertTrue( -1024550 == str2mnyCE(" -102,455.07", '.', 1) );
5  assertTrue( -102455 == str2mnyCE(" -102,455.07", '.', 0) );
6 
7  assertTrue( 1024558700 == str2mnyCE(" 102,455.87", '.', 4) );
8  assertTrue( 102455870 == str2mnyCE(" 102,455.87", '.', 3) );
9  assertTrue( 10245587 == str2mnyCE(" 102,455.87", '.', 2) );
10  assertTrue( 1024558 == str2mnyCE(" 102,455.87", '.', 1) );
11  assertTrue( 102455 == str2mnyCE(" 102,455.87", '.', 0) );
12 }}

See also
str2mnyCE.c

Definition at line 40 of file str2mnyCE.c.