PR tree-optimization/33856
[official-gcc.git] / libdecnumber / decDouble.h
blob32eba395d8570d777d228f2b05cd3c49f445d1ac
1 /* decDouble module header for the decNumber C Library.
2 Copyright (C) 2007 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 2, or (at your option) any later
10 version.
12 In addition to the permissions in the GNU General Public License,
13 the Free Software Foundation gives you unlimited permission to link
14 the compiled version of this file into combinations with other
15 programs, and to distribute those combinations without any
16 restriction coming from the use of this file. (The General Public
17 License restrictions do apply in other respects; for example, they
18 cover modification of the file, and distribution when not linked
19 into a combine executable.)
21 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22 WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 for more details.
26 You should have received a copy of the GNU General Public License
27 along with GCC; see the file COPYING. If not, write to the Free
28 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29 02110-1301, USA. */
31 /* ------------------------------------------------------------------ */
32 /* decDouble.h -- Decimal 64-bit format module header */
33 /* ------------------------------------------------------------------ */
34 /* Please see decFloats.h for an overview and documentation details. */
35 /* ------------------------------------------------------------------ */
37 #if !defined(DECDOUBLE)
38 #define DECDOUBLE
40 #define DECDOUBLENAME "decimalDouble" /* Short name */
41 #define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */
42 #define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */
44 /* parameters for decDoubles */
45 #define DECDOUBLE_Bytes 8 /* length */
46 #define DECDOUBLE_Pmax 16 /* maximum precision (digits) */
47 #define DECDOUBLE_Emin -383 /* minimum adjusted exponent */
48 #define DECDOUBLE_Emax 384 /* maximum adjusted exponent */
49 #define DECDOUBLE_EmaxD 3 /* maximum exponent digits */
50 #define DECDOUBLE_Bias 398 /* bias for the exponent */
51 #define DECDOUBLE_String 25 /* maximum string length, +1 */
52 #define DECDOUBLE_EconL 8 /* exponent continuation length */
53 #define DECDOUBLE_Declets 5 /* count of declets */
54 /* highest biased exponent (Elimit-1) */
55 #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1))
57 /* Required includes */
58 #include "decContext.h"
59 #include "decQuad.h"
61 /* The decDouble decimal 64-bit type, accessible by bytes */
62 typedef struct {
63 uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */
64 } decDouble;
66 /* ---------------------------------------------------------------- */
67 /* Routines -- implemented as decFloat routines in common files */
68 /* ---------------------------------------------------------------- */
70 #include "decDoubleSymbols.h"
72 /* Utilities and conversions, extractors, etc.) */
73 extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
74 extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
75 extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
76 extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
77 extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
78 extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
79 extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *);
80 extern int32_t decDoubleGetExponent(const decDouble *);
81 extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
82 extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
83 extern void decDoubleShow(const decDouble *, const char *);
84 extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
85 extern char * decDoubleToEngString(const decDouble *, char *);
86 extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding);
87 extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
88 extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
89 extern char * decDoubleToString(const decDouble *, char *);
90 extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
91 extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
92 extern decQuad * decDoubleToWider(const decDouble *, decQuad *);
93 extern decDouble * decDoubleZero(decDouble *);
95 /* Computational (result is a decDouble) */
96 extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
97 extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
98 extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
99 extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
100 extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
101 extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
102 extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
103 extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
104 extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
105 extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
106 extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
107 extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
108 extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
109 extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
110 extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
111 extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
112 extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
113 extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
114 extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
115 extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
116 extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
117 extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
118 extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
119 extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
120 extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
121 extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
122 extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
123 extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
124 extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
125 extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);
127 /* Comparisons */
128 extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
129 extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
130 extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
131 extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);
133 /* Copies */
134 extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
135 extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
136 extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
137 extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
138 extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);
140 /* Non-computational */
141 extern enum decClass decDoubleClass(const decDouble *);
142 extern const char * decDoubleClassString(const decDouble *);
143 extern uint32_t decDoubleDigits(const decDouble *);
144 extern uint32_t decDoubleIsCanonical(const decDouble *);
145 extern uint32_t decDoubleIsFinite(const decDouble *);
146 extern uint32_t decDoubleIsInfinite(const decDouble *);
147 extern uint32_t decDoubleIsInteger(const decDouble *);
148 extern uint32_t decDoubleIsNaN(const decDouble *);
149 extern uint32_t decDoubleIsNormal(const decDouble *);
150 extern uint32_t decDoubleIsSignaling(const decDouble *);
151 extern uint32_t decDoubleIsSignalling(const decDouble *);
152 extern uint32_t decDoubleIsSigned(const decDouble *);
153 extern uint32_t decDoubleIsSubnormal(const decDouble *);
154 extern uint32_t decDoubleIsZero(const decDouble *);
155 extern uint32_t decDoubleRadix(const decDouble *);
156 extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *);
157 extern const char * decDoubleVersion(void);
159 /* decNumber conversions; these are implemented as macros so as not */
160 /* to force a dependency on decimal64 and decNumber in decDouble. */
161 #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
162 #define decDoubleFromNumber(dq, dn, set) (decDouble *)decimal64FromNumber((decimal64 *)(dq), dn, set)
164 #endif