1
#ifndef PGTYPES_NUMERIC
2
#define PGTYPES_NUMERIC
4
#define NUMERIC_POS 0x0000
5
#define NUMERIC_NEG 0x4000
6
#define NUMERIC_NAN 0xC000
7
#define NUMERIC_MAX_PRECISION 1000
8
#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
9
#define NUMERIC_MIN_DISPLAY_SCALE 0
10
#define NUMERIC_MIN_SIG_DIGITS 16
14
typedef unsigned char NumericDigit;
17
int ndigits; /* number of digits in digits[] - can be
19
int weight; /* weight of first digit */
20
int rscale; /* result scale */
21
int dscale; /* display scale */
22
int sign; /* NUMERIC_POS, NUMERIC_NEG, or
24
NumericDigit *buf; /* start of alloc'd space for digits[] */
25
NumericDigit *digits; /* decimal digits */
30
int ndigits; /* number of digits in digits[] - can be
32
int weight; /* weight of first digit */
33
int rscale; /* result scale */
34
int dscale; /* display scale */
35
int sign; /* NUMERIC_POS, NUMERIC_NEG, or
37
NumericDigit digits[DECSIZE]; /* decimal digits */
45
numeric *PGTYPESnumeric_new(void);
46
void PGTYPESnumeric_free(numeric *);
47
numeric *PGTYPESnumeric_from_asc(char *, char **);
48
char *PGTYPESnumeric_to_asc(numeric *, int);
49
int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
50
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
51
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
52
int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
53
int PGTYPESnumeric_cmp(numeric *, numeric *);
54
int PGTYPESnumeric_from_int(signed int, numeric *);
55
int PGTYPESnumeric_from_long(signed long int, numeric *);
56
int PGTYPESnumeric_copy(numeric *, numeric *);
57
int PGTYPESnumeric_from_double(double, numeric *);
58
int PGTYPESnumeric_to_double(numeric *, double *);
59
int PGTYPESnumeric_to_int(numeric *, int *);
60
int PGTYPESnumeric_to_long(numeric *, long *);
61
int PGTYPESnumeric_to_decimal(numeric *, decimal *);
62
int PGTYPESnumeric_from_decimal(decimal *, numeric *);
68
#endif /* PGTYPES_NUMERIC */