1 /* decNumber package local type, tuning, and macro definitions.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Contributed by IBM Corporation. Author Mike Cowlishaw.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 In addition to the permissions in the GNU General Public License,
13 the Free Software Foundation gives you unlimited permission to link
14 the compiled version of this file into combinations with other
15 programs, and to distribute those combinations without any
16 restriction coming from the use of this file. (The General Public
17 License restrictions do apply in other respects; for example, they
18 cover modification of the file, and distribution when not linked
19 into a combine executable.)
21 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22 WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 You should have received a copy of the GNU General Public License
27 along with GCC; see the file COPYING. If not, write to the Free
28 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
31 /* ------------------------------------------------------------------ */
32 /* This header file is included by all modules in the decNumber */
33 /* library, and contains local type definitions, tuning parameters, */
34 /* etc. It must only be included once, and should not need to be */
35 /* used by application programs. decNumber.h must be included first. */
36 /* ------------------------------------------------------------------ */
38 #if !defined(DECNUMBERLOC)
40 #define DECNLAUTHOR "Mike Cowlishaw" /* Who to blame */
42 /* Local names for common types -- decNumber modules do not use int or
48 #define uShort uint16_t
51 #define Unit decNumberUnit
54 /* Tuning parameter */
55 #define DECBUFFER 36 /* Maximum size basis for local buffers. */
56 /* Should be a common maximum precision */
57 /* rounded up to a multiple of 4; must */
58 /* be non-negative. */
60 /* Conditional code flags -- set these to 0 for best performance */
61 #define DECCHECK 0 /* 1 to enable robust checking */
62 #define DECALLOC 0 /* 1 to enable memory allocation accounting */
63 #define DECTRACE 0 /* 1 to trace critical intermediates, etc. */
66 /* Development use defines */
68 /* if these interfere with your C includes, just comment them out */
69 #define int ? /* enable to ensure we do not use plain C */
70 #define long ?? /* .. 'int' or 'long' types from here on */
73 /* Limits and constants */
74 #define DECNUMMAXP 999999999 /* maximum precision we can handle (9 digits) */
75 #define DECNUMMAXE 999999999 /* maximum adjusted exponent ditto (9 digits) */
76 #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto (9 digits) */
77 #if (DECNUMMAXP != DEC_MAX_DIGITS)
78 #error Maximum digits mismatch
80 #if (DECNUMMAXE != DEC_MAX_EMAX)
81 #error Maximum exponent mismatch
83 #if (DECNUMMINE != DEC_MIN_EMIN)
84 #error Minimum exponent mismatch
87 /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN digits */
93 #define DECDPUNMAX 999
95 #define DECDPUNMAX 9999
97 #define DECDPUNMAX 99999
99 #define DECDPUNMAX 999999
101 #define DECDPUNMAX 9999999
103 #define DECDPUNMAX 99999999
105 #define DECDPUNMAX 999999999
106 #elif defined(DECDPUN)
107 #error DECDPUN must be in the range 1-9
111 /* ----- Shared data ----- */
112 /* The powers of of ten array (powers[n]==10**n, 0<=n<=10) */
113 extern const uInt powers
[];
115 /* ----- Macros ----- */
116 /* ISZERO -- return true if decNumber dn is a zero */
117 /* [performance-critical in some situations] */
118 #define ISZERO(dn) decNumberIsZero(dn) /* now just a local name */
120 /* X10 and X100 -- multiply integer i by 10 or 100 */
121 /* [shifts are usually faster than multiply; could be conditional] */
122 #define X10(i) (((i)<<1)+((i)<<3))
123 #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
125 /* D2U -- return the number of Units needed to hold d digits */
127 #define D2U(d) ((unsigned)((d)+7)>>3)
129 #define D2U(d) ((unsigned)((d)+3)>>2)
131 #define D2U(d) (((d)+DECDPUN-1)/DECDPUN)
135 #error decNumberLocal included more than once