1 /* decDouble module header for the decNumber C Library.
2 Copyright (C) 2007, 2009 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 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* ------------------------------------------------------------------ */
27 /* decDouble.h -- Decimal 64-bit format module header */
28 /* ------------------------------------------------------------------ */
30 #if !defined(DECDOUBLE)
33 #define DECDOUBLENAME "decimalDouble" /* Short name */
34 #define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */
35 #define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */
37 /* parameters for decDoubles */
38 #define DECDOUBLE_Bytes 8 /* length */
39 #define DECDOUBLE_Pmax 16 /* maximum precision (digits) */
40 #define DECDOUBLE_Emin -383 /* minimum adjusted exponent */
41 #define DECDOUBLE_Emax 384 /* maximum adjusted exponent */
42 #define DECDOUBLE_EmaxD 3 /* maximum exponent digits */
43 #define DECDOUBLE_Bias 398 /* bias for the exponent */
44 #define DECDOUBLE_String 25 /* maximum string length, +1 */
45 #define DECDOUBLE_EconL 8 /* exponent continuation length */
46 #define DECDOUBLE_Declets 5 /* count of declets */
47 /* highest biased exponent (Elimit-1) */
48 #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))
50 /* Required includes */
51 #include "decContext.h"
54 /* The decDouble decimal 64-bit type, accessible by all sizes */
56 uint8_t bytes
[DECDOUBLE_Bytes
]; /* fields: 1, 5, 8, 50 bits */
57 uint16_t shorts
[DECDOUBLE_Bytes
/2];
58 uint32_t words
[DECDOUBLE_Bytes
/4];
60 uint64_t longs
[DECDOUBLE_Bytes
/8];
64 /* ---------------------------------------------------------------- */
65 /* Routines -- implemented as decFloat routines in common files */
66 /* ---------------------------------------------------------------- */
68 #include "decDoubleSymbols.h"
70 /* Utilities and conversions, extractors, etc.) */
71 extern decDouble
* decDoubleFromBCD(decDouble
*, int32_t, const uint8_t *, int32_t);
72 extern decDouble
* decDoubleFromInt32(decDouble
*, int32_t);
73 extern decDouble
* decDoubleFromPacked(decDouble
*, int32_t, const uint8_t *);
74 extern decDouble
* decDoubleFromPackedChecked(decDouble
*, int32_t, const uint8_t *);
75 extern decDouble
* decDoubleFromString(decDouble
*, const char *, decContext
*);
76 extern decDouble
* decDoubleFromUInt32(decDouble
*, uint32_t);
77 extern decDouble
* decDoubleFromWider(decDouble
*, const decQuad
*, decContext
*);
78 extern int32_t decDoubleGetCoefficient(const decDouble
*, uint8_t *);
79 extern int32_t decDoubleGetExponent(const decDouble
*);
80 extern decDouble
* decDoubleSetCoefficient(decDouble
*, const uint8_t *, int32_t);
81 extern decDouble
* decDoubleSetExponent(decDouble
*, decContext
*, int32_t);
82 extern void decDoubleShow(const decDouble
*, const char *);
83 extern int32_t decDoubleToBCD(const decDouble
*, int32_t *, uint8_t *);
84 extern char * decDoubleToEngString(const decDouble
*, char *);
85 extern int32_t decDoubleToInt32(const decDouble
*, decContext
*, enum rounding
);
86 extern int32_t decDoubleToInt32Exact(const decDouble
*, decContext
*, enum rounding
);
87 extern int32_t decDoubleToPacked(const decDouble
*, int32_t *, uint8_t *);
88 extern char * decDoubleToString(const decDouble
*, char *);
89 extern uint32_t decDoubleToUInt32(const decDouble
*, decContext
*, enum rounding
);
90 extern uint32_t decDoubleToUInt32Exact(const decDouble
*, decContext
*, enum rounding
);
91 extern decQuad
* decDoubleToWider(const decDouble
*, decQuad
*);
92 extern decDouble
* decDoubleZero(decDouble
*);
94 /* Computational (result is a decDouble) */
95 extern decDouble
* decDoubleAbs(decDouble
*, const decDouble
*, decContext
*);
96 extern decDouble
* decDoubleAdd(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
97 extern decDouble
* decDoubleAnd(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
98 extern decDouble
* decDoubleDivide(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
99 extern decDouble
* decDoubleDivideInteger(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
100 extern decDouble
* decDoubleFMA(decDouble
*, const decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
101 extern decDouble
* decDoubleInvert(decDouble
*, const decDouble
*, decContext
*);
102 extern decDouble
* decDoubleLogB(decDouble
*, const decDouble
*, decContext
*);
103 extern decDouble
* decDoubleMax(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
104 extern decDouble
* decDoubleMaxMag(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
105 extern decDouble
* decDoubleMin(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
106 extern decDouble
* decDoubleMinMag(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
107 extern decDouble
* decDoubleMinus(decDouble
*, const decDouble
*, decContext
*);
108 extern decDouble
* decDoubleMultiply(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
109 extern decDouble
* decDoubleNextMinus(decDouble
*, const decDouble
*, decContext
*);
110 extern decDouble
* decDoubleNextPlus(decDouble
*, const decDouble
*, decContext
*);
111 extern decDouble
* decDoubleNextToward(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
112 extern decDouble
* decDoubleOr(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
113 extern decDouble
* decDoublePlus(decDouble
*, const decDouble
*, decContext
*);
114 extern decDouble
* decDoubleQuantize(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
115 extern decDouble
* decDoubleReduce(decDouble
*, const decDouble
*, decContext
*);
116 extern decDouble
* decDoubleRemainder(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
117 extern decDouble
* decDoubleRemainderNear(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
118 extern decDouble
* decDoubleRotate(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
119 extern decDouble
* decDoubleScaleB(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
120 extern decDouble
* decDoubleShift(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
121 extern decDouble
* decDoubleSubtract(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
122 extern decDouble
* decDoubleToIntegralValue(decDouble
*, const decDouble
*, decContext
*, enum rounding
);
123 extern decDouble
* decDoubleToIntegralExact(decDouble
*, const decDouble
*, decContext
*);
124 extern decDouble
* decDoubleXor(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
127 extern decDouble
* decDoubleCompare(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
128 extern decDouble
* decDoubleCompareSignal(decDouble
*, const decDouble
*, const decDouble
*, decContext
*);
129 extern decDouble
* decDoubleCompareTotal(decDouble
*, const decDouble
*, const decDouble
*);
130 extern decDouble
* decDoubleCompareTotalMag(decDouble
*, const decDouble
*, const decDouble
*);
133 extern decDouble
* decDoubleCanonical(decDouble
*, const decDouble
*);
134 extern decDouble
* decDoubleCopy(decDouble
*, const decDouble
*);
135 extern decDouble
* decDoubleCopyAbs(decDouble
*, const decDouble
*);
136 extern decDouble
* decDoubleCopyNegate(decDouble
*, const decDouble
*);
137 extern decDouble
* decDoubleCopySign(decDouble
*, const decDouble
*, const decDouble
*);
139 /* Non-computational */
140 extern enum decClass
decDoubleClass(const decDouble
*);
141 extern const char * decDoubleClassString(const decDouble
*);
142 extern uint32_t decDoubleDigits(const decDouble
*);
143 extern uint32_t decDoubleIsCanonical(const decDouble
*);
144 extern uint32_t decDoubleIsFinite(const decDouble
*);
145 extern uint32_t decDoubleIsInfinite(const decDouble
*);
146 extern uint32_t decDoubleIsInteger(const decDouble
*);
147 extern uint32_t decDoubleIsNaN(const decDouble
*);
148 extern uint32_t decDoubleIsNormal(const decDouble
*);
149 extern uint32_t decDoubleIsSignaling(const decDouble
*);
150 extern uint32_t decDoubleIsSignalling(const decDouble
*);
151 extern uint32_t decDoubleIsSigned(const decDouble
*);
152 extern uint32_t decDoubleIsSubnormal(const decDouble
*);
153 extern uint32_t decDoubleIsZero(const decDouble
*);
154 extern uint32_t decDoubleRadix(const decDouble
*);
155 extern uint32_t decDoubleSameQuantum(const decDouble
*, const decDouble
*);
156 extern const char * decDoubleVersion(void);
158 /* decNumber conversions; these are implemented as macros so as not */
159 /* to force a dependency on decimal64 and decNumber in decDouble. */
160 /* decDoubleFromNumber returns a decimal64 * to avoid warnings. */
161 #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
162 #define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)