1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #if !defined(DECDOUBLE)
24 # define DECDOUBLE
25
26 # define DECDOUBLENAME "decimalDouble"
27 # define DECDOUBLETITLE "Decimal 64-bit datum"
28 # define DECDOUBLEAUTHOR "Mike Cowlishaw"
29
30
31 # define DECDOUBLE_Bytes 8
32 # define DECDOUBLE_Pmax 16
33 # define DECDOUBLE_Emin -383
34 # define DECDOUBLE_Emax 384
35 # define DECDOUBLE_EmaxD 3
36 # define DECDOUBLE_Bias 398
37 # define DECDOUBLE_String 25
38 # define DECDOUBLE_EconL 8
39 # define DECDOUBLE_Declets 5
40
41 # define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))
42
43
44 # include "decContext.h"
45 # include "decQuad.h"
46
47
48 typedef union {
49 uint8_t bytes[DECDOUBLE_Bytes];
50 uint16_t shorts[DECDOUBLE_Bytes/2];
51 uint32_t words[DECDOUBLE_Bytes/4];
52 # if DECUSE64
53 uint64_t longs[DECDOUBLE_Bytes/8];
54 # endif
55 } decDouble;
56
57
58
59
60
61
62 extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
63 extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
64 extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
65 extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);
66 extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
67 extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
68 extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
69 extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *);
70 extern int32_t decDoubleGetExponent(const decDouble *);
71 extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
72 extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
73 extern void decDoubleShow(const decDouble *, const char *);
74 extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
75 extern char * decDoubleToEngString(const decDouble *, char *);
76 extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding);
77 extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
78 extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
79 extern char * decDoubleToString(const decDouble *, char *);
80 extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
81 extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
82 extern decQuad * decDoubleToWider(const decDouble *, decQuad *);
83 extern decDouble * decDoubleZero(decDouble *);
84
85
86 extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
87 extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
88 extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
89 extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
90 extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
91 extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
92 extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
93 extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
94 extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
95 extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
96 extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
97 extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
98 extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
99 extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
100 extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
101 extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
102 extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
103 extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
104 extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
105 extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
106 extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
107 extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
108 extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
109 extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
110 extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
111 extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
112 extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
113 extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
114 extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
115 extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);
116
117
118 extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
119 extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
120 extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
121 extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);
122
123
124 extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
125 extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
126 extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
127 extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
128 extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);
129
130
131 extern enum decClass decDoubleClass(const decDouble *);
132 extern const char * decDoubleClassString(const decDouble *);
133 extern uint32_t decDoubleDigits(const decDouble *);
134 extern uint32_t decDoubleIsCanonical(const decDouble *);
135 extern uint32_t decDoubleIsFinite(const decDouble *);
136 extern uint32_t decDoubleIsInfinite(const decDouble *);
137 extern uint32_t decDoubleIsInteger(const decDouble *);
138 extern uint32_t decDoubleIsLogical(const decDouble *);
139 extern uint32_t decDoubleIsNaN(const decDouble *);
140 extern uint32_t decDoubleIsNegative(const decDouble *);
141 extern uint32_t decDoubleIsNormal(const decDouble *);
142 extern uint32_t decDoubleIsPositive(const decDouble *);
143 extern uint32_t decDoubleIsSignaling(const decDouble *);
144 extern uint32_t decDoubleIsSignalling(const decDouble *);
145 extern uint32_t decDoubleIsSigned(const decDouble *);
146 extern uint32_t decDoubleIsSubnormal(const decDouble *);
147 extern uint32_t decDoubleIsZero(const decDouble *);
148 extern uint32_t decDoubleRadix(const decDouble *);
149 extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *);
150 extern const char * decDoubleVersion(void);
151
152
153
154
155 # define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
156 # define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)
157
158 #endif