2009-01-26 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / libdecnumber / decDouble.h
blob53fcf406bec5608854c2d398f8019f4706db2aea
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 various types */
62 typedef union {
63 uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */
64 uint16_t shorts[DECDOUBLE_Bytes/2];
65 uint32_t words[DECDOUBLE_Bytes/4];
66 } decDouble;
68 /* ---------------------------------------------------------------- */
69 /* Routines -- implemented as decFloat routines in common files */
70 /* ---------------------------------------------------------------- */
72 #include "decDoubleSymbols.h"
74 /* Utilities and conversions, extractors, etc.) */
75 extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
76 extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
77 extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
78 extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
79 extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
80 extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
81 extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *);
82 extern int32_t decDoubleGetExponent(const decDouble *);
83 extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t);
84 extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t);
85 extern void decDoubleShow(const decDouble *, const char *);
86 extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *);
87 extern char * decDoubleToEngString(const decDouble *, char *);
88 extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding);
89 extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding);
90 extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *);
91 extern char * decDoubleToString(const decDouble *, char *);
92 extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding);
93 extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding);
94 extern decQuad * decDoubleToWider(const decDouble *, decQuad *);
95 extern decDouble * decDoubleZero(decDouble *);
97 /* Computational (result is a decDouble) */
98 extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *);
99 extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *);
100 extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *);
101 extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *);
102 extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *);
103 extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *);
104 extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *);
105 extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *);
106 extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *);
107 extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *);
108 extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *);
109 extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *);
110 extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *);
111 extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *);
112 extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *);
113 extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *);
114 extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *);
115 extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *);
116 extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *);
117 extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *);
118 extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *);
119 extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *);
120 extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *);
121 extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *);
122 extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *);
123 extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *);
124 extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *);
125 extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding);
126 extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *);
127 extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *);
129 /* Comparisons */
130 extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *);
131 extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *);
132 extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *);
133 extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *);
135 /* Copies */
136 extern decDouble * decDoubleCanonical(decDouble *, const decDouble *);
137 extern decDouble * decDoubleCopy(decDouble *, const decDouble *);
138 extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *);
139 extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *);
140 extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *);
142 /* Non-computational */
143 extern enum decClass decDoubleClass(const decDouble *);
144 extern const char * decDoubleClassString(const decDouble *);
145 extern uint32_t decDoubleDigits(const decDouble *);
146 extern uint32_t decDoubleIsCanonical(const decDouble *);
147 extern uint32_t decDoubleIsFinite(const decDouble *);
148 extern uint32_t decDoubleIsInfinite(const decDouble *);
149 extern uint32_t decDoubleIsInteger(const decDouble *);
150 extern uint32_t decDoubleIsNaN(const decDouble *);
151 extern uint32_t decDoubleIsNormal(const decDouble *);
152 extern uint32_t decDoubleIsSignaling(const decDouble *);
153 extern uint32_t decDoubleIsSignalling(const decDouble *);
154 extern uint32_t decDoubleIsSigned(const decDouble *);
155 extern uint32_t decDoubleIsSubnormal(const decDouble *);
156 extern uint32_t decDoubleIsZero(const decDouble *);
157 extern uint32_t decDoubleRadix(const decDouble *);
158 extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *);
159 extern const char * decDoubleVersion(void);
161 /* decNumber conversions; these are implemented as macros so as not */
162 /* to force a dependency on decimal64 and decNumber in decDouble. */
163 #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
164 #define decDoubleFromNumber(dq, dn, set) (decDouble *)decimal64FromNumber((decimal64 *)(dq), dn, set)
166 #endif