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