/Users/deen/code/yugabyte-db/src/postgres/src/interfaces/ecpg/include/pgtypes_numeric.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef PGTYPES_NUMERIC |
2 | | #define PGTYPES_NUMERIC |
3 | | |
4 | | #include <pgtypes.h> |
5 | | |
6 | 2.22k | #define NUMERIC_POS 0x0000 |
7 | 0 | #define NUMERIC_NEG 0x4000 |
8 | | #define NUMERIC_NAN 0xC000 |
9 | 0 | #define NUMERIC_NULL 0xF000 |
10 | | #define NUMERIC_MAX_PRECISION 1000 |
11 | | #define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION |
12 | | #define NUMERIC_MIN_DISPLAY_SCALE 0 |
13 | 3.09k | #define NUMERIC_MIN_SIG_DIGITS 16 |
14 | | |
15 | 0 | #define DECSIZE 30 |
16 | | |
17 | | typedef unsigned char NumericDigit; |
18 | | typedef struct |
19 | | { |
20 | | int ndigits; /* number of digits in digits[] - can be 0! */ |
21 | | int weight; /* weight of first digit */ |
22 | | int rscale; /* result scale */ |
23 | | int dscale; /* display scale */ |
24 | | int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ |
25 | | NumericDigit *buf; /* start of alloc'd space for digits[] */ |
26 | | NumericDigit *digits; /* decimal digits */ |
27 | | } numeric; |
28 | | |
29 | | typedef struct |
30 | | { |
31 | | int ndigits; /* number of digits in digits[] - can be 0! */ |
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 NUMERIC_NAN */ |
36 | | NumericDigit digits[DECSIZE]; /* decimal digits */ |
37 | | } decimal; |
38 | | |
39 | | #ifdef __cplusplus |
40 | | extern "C" |
41 | | { |
42 | | #endif |
43 | | |
44 | | numeric *PGTYPESnumeric_new(void); |
45 | | decimal *PGTYPESdecimal_new(void); |
46 | | void PGTYPESnumeric_free(numeric *); |
47 | | void PGTYPESdecimal_free(decimal *); |
48 | | numeric *PGTYPESnumeric_from_asc(char *, char **); |
49 | | char *PGTYPESnumeric_to_asc(numeric *, int); |
50 | | int PGTYPESnumeric_add(numeric *, numeric *, numeric *); |
51 | | int PGTYPESnumeric_sub(numeric *, numeric *, numeric *); |
52 | | int PGTYPESnumeric_mul(numeric *, numeric *, numeric *); |
53 | | int PGTYPESnumeric_div(numeric *, numeric *, numeric *); |
54 | | int PGTYPESnumeric_cmp(numeric *, numeric *); |
55 | | int PGTYPESnumeric_from_int(signed int, numeric *); |
56 | | int PGTYPESnumeric_from_long(signed long int, numeric *); |
57 | | int PGTYPESnumeric_copy(numeric *, numeric *); |
58 | | int PGTYPESnumeric_from_double(double, numeric *); |
59 | | int PGTYPESnumeric_to_double(numeric *, double *); |
60 | | int PGTYPESnumeric_to_int(numeric *, int *); |
61 | | int PGTYPESnumeric_to_long(numeric *, long *); |
62 | | int PGTYPESnumeric_to_decimal(numeric *, decimal *); |
63 | | int PGTYPESnumeric_from_decimal(decimal *, numeric *); |
64 | | |
65 | | #ifdef __cplusplus |
66 | | } |
67 | | #endif |
68 | | |
69 | | #endif /* PGTYPES_NUMERIC */ |