1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #if !defined(DECQUAD)
25 # define DECQUAD
26
27 # define DECQUADNAME "decimalQuad"
28 # define DECQUADTITLE "Decimal 128-bit datum"
29 # define DECQUADAUTHOR "Mike Cowlishaw"
30
31
32 # define DECQUAD_Bytes 16
33 # define DECQUAD_Pmax 34
34 # define DECQUAD_Emin -6143
35 # define DECQUAD_Emax 6144
36 # define DECQUAD_EmaxD 4
37 # define DECQUAD_Bias 6176
38 # define DECQUAD_String 43
39 # define DECQUAD_EconL 12
40 # define DECQUAD_Declets 11
41
42 # define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
43
44
45 # include "decContext.h"
46
47
48 typedef union {
49 uint8_t bytes[DECQUAD_Bytes];
50 uint16_t shorts[DECQUAD_Bytes/2];
51 uint32_t words[DECQUAD_Bytes/4];
52 # if DECUSE64
53 uint64_t longs[DECQUAD_Bytes/8];
54 # endif
55 } decQuad;
56
57
58
59
60
61
62
63 # define DECFLOAT_Sign 0x80000000
64 # define DECFLOAT_NaN 0x7c000000
65 # define DECFLOAT_qNaN 0x7c000000
66 # define DECFLOAT_sNaN 0x7e000000
67 # define DECFLOAT_Inf 0x78000000
68 # define DECFLOAT_MinSp 0x78000000
69
70
71 # if !defined(DECPPLUSALT)
72 # define DECPPLUSALT 0x0A
73 # define DECPMINUSALT 0x0B
74 # define DECPPLUS 0x0C
75 # define DECPMINUS 0x0D
76 # define DECPPLUSALT2 0x0E
77 # define DECPUNSIGNED 0x0F
78 # endif
79
80
81
82
83
84
85 extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
86 extern decQuad * decQuadFromInt32(decQuad *, int32_t);
87 extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
88 extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);
89 extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
90 extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
91 extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *);
92 extern int32_t decQuadGetExponent(const decQuad *);
93 extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);
94 extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);
95 extern void decQuadShow(const decQuad *, const char *);
96 extern int32_t decQuadToBCD(const decQuad *, int32_t *, uint8_t *);
97 extern char * decQuadToEngString(const decQuad *, char *);
98 extern int32_t decQuadToInt32(const decQuad *, decContext *, enum rounding);
99 extern int32_t decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);
100 extern int32_t decQuadToPacked(const decQuad *, int32_t *, uint8_t *);
101 extern char * decQuadToString(const decQuad *, char *);
102 extern uint32_t decQuadToUInt32(const decQuad *, decContext *, enum rounding);
103 extern uint32_t decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);
104 extern decQuad * decQuadZero(decQuad *);
105
106
107 extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);
108 extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);
109 extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);
110 extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);
111 extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);
112 extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);
113 extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);
114 extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);
115 extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);
116 extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);
117 extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);
118 extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);
119 extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);
120 extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);
121 extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);
122 extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);
123 extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);
124 extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);
125 extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);
126 extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);
127 extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);
128 extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);
129 extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);
130 extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);
131 extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);
132 extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);
133 extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);
134 extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);
135 extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);
136 extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);
137
138
139 extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);
140 extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);
141 extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);
142 extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);
143
144
145 extern decQuad * decQuadCanonical(decQuad *, const decQuad *);
146 extern decQuad * decQuadCopy(decQuad *, const decQuad *);
147 extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);
148 extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);
149 extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);
150
151
152 extern enum decClass decQuadClass(const decQuad *);
153 extern const char * decQuadClassString(const decQuad *);
154 extern uint32_t decQuadDigits(const decQuad *);
155 extern uint32_t decQuadIsCanonical(const decQuad *);
156 extern uint32_t decQuadIsFinite(const decQuad *);
157 extern uint32_t decQuadIsInteger(const decQuad *);
158 extern uint32_t decQuadIsLogical(const decQuad *);
159 extern uint32_t decQuadIsInfinite(const decQuad *);
160 extern uint32_t decQuadIsNaN(const decQuad *);
161 extern uint32_t decQuadIsNegative(const decQuad *);
162 extern uint32_t decQuadIsNormal(const decQuad *);
163 extern uint32_t decQuadIsPositive(const decQuad *);
164 extern uint32_t decQuadIsSignaling(const decQuad *);
165 extern uint32_t decQuadIsSignalling(const decQuad *);
166 extern uint32_t decQuadIsSigned(const decQuad *);
167 extern uint32_t decQuadIsSubnormal(const decQuad *);
168 extern uint32_t decQuadIsZero(const decQuad *);
169 extern uint32_t decQuadRadix(const decQuad *);
170 extern uint32_t decQuadSameQuantum(const decQuad *, const decQuad *);
171 extern const char * decQuadVersion(void);
172
173
174
175
176 # define decQuadToNumber(dq, dn) \
177 decimal128ToNumber((decimal128 *)(dq), dn)
178 # define decQuadFromNumber(dq, dn, set) \
179 decimal128FromNumber((decimal128 *)(dq), dn, set)
180
181 #endif