~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/include/pgtypes_numeric.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_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
 
11
 
 
12
#define DECSIZE 30
 
13
 
 
14
typedef unsigned char NumericDigit;
 
15
typedef struct
 
16
{
 
17
        int                     ndigits;                /* number of digits in digits[] - can be
 
18
                                                                 * 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
 
23
                                                                 * NUMERIC_NAN */
 
24
        NumericDigit *buf;                      /* start of alloc'd space for digits[] */
 
25
        NumericDigit *digits;           /* decimal digits */
 
26
} numeric;
 
27
 
 
28
typedef struct
 
29
{
 
30
        int                     ndigits;                /* number of digits in digits[] - can be
 
31
                                                                 * 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
 
36
                                                                 * NUMERIC_NAN */
 
37
        NumericDigit digits[DECSIZE];           /* decimal digits */
 
38
} decimal;
 
39
 
 
40
#ifdef __cplusplus
 
41
extern          "C"
 
42
{
 
43
#endif
 
44
 
 
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 *);
 
63
 
 
64
#ifdef __cplusplus
 
65
}
 
66
#endif
 
67
 
 
68
#endif   /* PGTYPES_NUMERIC */