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