PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pgtypes_numeric.h
Go to the documentation of this file.
1 #ifndef PGTYPES_NUMERIC
2 #define PGTYPES_NUMERIC
3 
4 #define NUMERIC_POS 0x0000
5 #define NUMERIC_NEG 0x4000
6 #define NUMERIC_NAN 0xC000
7 #define NUMERIC_NULL 0xF000
8 #define NUMERIC_MAX_PRECISION 1000
9 #define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION
10 #define NUMERIC_MIN_DISPLAY_SCALE 0
11 #define NUMERIC_MIN_SIG_DIGITS 16
12 
13 #define DECSIZE 30
14 
15 typedef unsigned char NumericDigit;
16 typedef struct
17 {
18  int ndigits; /* number of digits in digits[] - can be 0! */
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 NUMERIC_NAN */
23  NumericDigit *buf; /* start of alloc'd space for digits[] */
24  NumericDigit *digits; /* decimal digits */
25 } numeric;
26 
27 typedef struct
28 {
29  int ndigits; /* number of digits in digits[] - can be 0! */
30  int weight; /* weight of first digit */
31  int rscale; /* result scale */
32  int dscale; /* display scale */
33  int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
34  NumericDigit digits[DECSIZE]; /* decimal digits */
35 } decimal;
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41 
46 numeric *PGTYPESnumeric_from_asc(char *, char **);
47 char *PGTYPESnumeric_to_asc(numeric *, int);
53 int PGTYPESnumeric_from_int(signed int, numeric *);
54 int PGTYPESnumeric_from_long(signed long int, numeric *);
56 int PGTYPESnumeric_from_double(double, numeric *);
57 int PGTYPESnumeric_to_double(numeric *, double *);
58 int PGTYPESnumeric_to_int(numeric *, int *);
59 int PGTYPESnumeric_to_long(numeric *, long *);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* PGTYPES_NUMERIC */
int PGTYPESnumeric_from_long(signed long int, numeric *)
Definition: numeric.c:1405
int PGTYPESnumeric_copy(numeric *, numeric *)
Definition: numeric.c:1475
int PGTYPESnumeric_from_decimal(decimal *, numeric *)
Definition: numeric.c:1652
unsigned char NumericDigit
decimal * PGTYPESdecimal_new(void)
Definition: numeric.c:144
int PGTYPESnumeric_to_decimal(numeric *, decimal *)
Definition: numeric.c:1629
NumericDigit * buf
int PGTYPESnumeric_from_double(double, numeric *)
Definition: numeric.c:1498
void PGTYPESnumeric_free(numeric *)
Definition: numeric.c:470
numeric * PGTYPESnumeric_new(void)
Definition: numeric.c:127
int PGTYPESnumeric_to_long(numeric *, long *)
Definition: numeric.c:1600
int PGTYPESnumeric_to_int(numeric *, int *)
Definition: numeric.c:1581
int PGTYPESnumeric_cmp(numeric *, numeric *)
Definition: numeric.c:1367
NumericDigit * digits
int PGTYPESnumeric_div(numeric *, numeric *, numeric *)
Definition: numeric.c:1138
Datum numeric(PG_FUNCTION_ARGS)
Definition: numeric.c:933
int16 NumericDigit
Definition: numeric.c:99
int PGTYPESnumeric_from_int(signed int, numeric *)
Definition: numeric.c:1396
char * PGTYPESnumeric_to_asc(numeric *, int)
Definition: numeric.c:428
numeric * PGTYPESnumeric_from_asc(char *, char **)
Definition: numeric.c:406
int PGTYPESnumeric_to_double(numeric *, double *)
Definition: numeric.c:1570
#define DECSIZE
void PGTYPESdecimal_free(decimal *)
Definition: numeric.c:477
int PGTYPESnumeric_add(numeric *, numeric *, numeric *)
Definition: numeric.c:722
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *)
Definition: numeric.c:981
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *)
Definition: numeric.c:850
int digits
Definition: informix.c:691