merge from gcc
[deliverable/binutils-gdb.git] / libdecnumber / decQuad.h
CommitLineData
f5bc1778
DJ
1/* decQuad module header for the decNumber C Library.
2 Copyright (C) 2007 Free Software Foundation, Inc.
3 Contributed by IBM Corporation. Author Mike Cowlishaw.
4
5 This file is part of GCC.
6
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.
11
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.)
20
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.
25
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. */
30
31/* ------------------------------------------------------------------ */
32/* decQuad.h -- Decimal 128-bit format module header */
33/* ------------------------------------------------------------------ */
f5bc1778 34/* This include file is always included by decSingle and decDouble, */
87d32bb7 35/* and therefore also holds useful constants used by all three. */
f5bc1778
DJ
36
37#if !defined(DECQUAD)
38 #define DECQUAD
39
40 #define DECQUADNAME "decimalQuad" /* Short name */
41 #define DECQUADTITLE "Decimal 128-bit datum" /* Verbose name */
87d32bb7 42 #define DECQUADAUTHOR "Mike Cowlishaw" /* Who to blame */
f5bc1778
DJ
43
44 /* parameters for decQuads */
87d32bb7 45 #define DECQUAD_Bytes 16 /* length */
f5bc1778 46 #define DECQUAD_Pmax 34 /* maximum precision (digits) */
87d32bb7
DD
47 #define DECQUAD_Emin -6143 /* minimum adjusted exponent */
48 #define DECQUAD_Emax 6144 /* maximum adjusted exponent */
49 #define DECQUAD_EmaxD 4 /* maximum exponent digits */
f5bc1778 50 #define DECQUAD_Bias 6176 /* bias for the exponent */
87d32bb7
DD
51 #define DECQUAD_String 43 /* maximum string length, +1 */
52 #define DECQUAD_EconL 12 /* exponent continuation length */
f5bc1778
DJ
53 #define DECQUAD_Declets 11 /* count of declets */
54 /* highest biased exponent (Elimit-1) */
55 #define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
56
57 /* Required include */
58 #include "decContext.h"
59
87d32bb7 60 /* The decQuad decimal 128-bit type, accessible by all sizes */
aed1add3 61 typedef union {
87d32bb7 62 uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */
aed1add3 63 uint16_t shorts[DECQUAD_Bytes/2];
87d32bb7
DD
64 uint32_t words[DECQUAD_Bytes/4];
65 #if DECUSE64
66 uint64_t longs[DECQUAD_Bytes/8];
67 #endif
f5bc1778
DJ
68 } decQuad;
69
70 /* ---------------------------------------------------------------- */
71 /* Shared constants */
72 /* ---------------------------------------------------------------- */
73
74 /* sign and special values [top 32-bits; last two bits are don't-care
75 for Infinity on input, last bit don't-care for NaNs] */
87d32bb7 76 #define DECFLOAT_Sign 0x80000000 /* 1 00000 00 Sign */
f5bc1778 77 #define DECFLOAT_NaN 0x7c000000 /* 0 11111 00 NaN generic */
87d32bb7
DD
78 #define DECFLOAT_qNaN 0x7c000000 /* 0 11111 00 qNaN */
79 #define DECFLOAT_sNaN 0x7e000000 /* 0 11111 10 sNaN */
f5bc1778
DJ
80 #define DECFLOAT_Inf 0x78000000 /* 0 11110 00 Infinity */
81 #define DECFLOAT_MinSp 0x78000000 /* minimum special value */
82 /* [specials are all >=MinSp] */
83 /* Sign nibble constants */
84 #if !defined(DECPPLUSALT)
87d32bb7
DD
85 #define DECPPLUSALT 0x0A /* alternate plus nibble */
86 #define DECPMINUSALT 0x0B /* alternate minus nibble */
87 #define DECPPLUS 0x0C /* preferred plus nibble */
88 #define DECPMINUS 0x0D /* preferred minus nibble */
89 #define DECPPLUSALT2 0x0E /* alternate plus nibble */
90 #define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
f5bc1778
DJ
91 #endif
92
93 /* ---------------------------------------------------------------- */
94 /* Routines -- implemented as decFloat routines in common files */
95 /* ---------------------------------------------------------------- */
96
97 #include "decQuadSymbols.h"
98
99 /* Utilities and conversions, extractors, etc.) */
100 extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
101 extern decQuad * decQuadFromInt32(decQuad *, int32_t);
102 extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
87d32bb7 103 extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);
f5bc1778
DJ
104 extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
105 extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
106 extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *);
107 extern int32_t decQuadGetExponent(const decQuad *);
108 extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t);
109 extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t);
110 extern void decQuadShow(const decQuad *, const char *);
111 extern int32_t decQuadToBCD(const decQuad *, int32_t *, uint8_t *);
112 extern char * decQuadToEngString(const decQuad *, char *);
113 extern int32_t decQuadToInt32(const decQuad *, decContext *, enum rounding);
114 extern int32_t decQuadToInt32Exact(const decQuad *, decContext *, enum rounding);
115 extern int32_t decQuadToPacked(const decQuad *, int32_t *, uint8_t *);
116 extern char * decQuadToString(const decQuad *, char *);
117 extern uint32_t decQuadToUInt32(const decQuad *, decContext *, enum rounding);
118 extern uint32_t decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding);
119 extern decQuad * decQuadZero(decQuad *);
120
121 /* Computational (result is a decQuad) */
122 extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *);
123 extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *);
124 extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *);
125 extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *);
126 extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *);
127 extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *);
128 extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *);
129 extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *);
130 extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *);
131 extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *);
132 extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *);
133 extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *);
134 extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *);
135 extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *);
136 extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *);
137 extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *);
138 extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *);
139 extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *);
140 extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *);
141 extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *);
142 extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *);
143 extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *);
144 extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *);
145 extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *);
146 extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *);
147 extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *);
148 extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *);
149 extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding);
150 extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *);
151 extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *);
152
153 /* Comparisons */
154 extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *);
155 extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *);
156 extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *);
157 extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *);
158
159 /* Copies */
160 extern decQuad * decQuadCanonical(decQuad *, const decQuad *);
161 extern decQuad * decQuadCopy(decQuad *, const decQuad *);
162 extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *);
163 extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *);
164 extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *);
165
166 /* Non-computational */
167 extern enum decClass decQuadClass(const decQuad *);
168 extern const char * decQuadClassString(const decQuad *);
169 extern uint32_t decQuadDigits(const decQuad *);
170 extern uint32_t decQuadIsCanonical(const decQuad *);
171 extern uint32_t decQuadIsFinite(const decQuad *);
172 extern uint32_t decQuadIsInteger(const decQuad *);
173 extern uint32_t decQuadIsInfinite(const decQuad *);
174 extern uint32_t decQuadIsNaN(const decQuad *);
175 extern uint32_t decQuadIsNormal(const decQuad *);
176 extern uint32_t decQuadIsSignaling(const decQuad *);
177 extern uint32_t decQuadIsSignalling(const decQuad *);
178 extern uint32_t decQuadIsSigned(const decQuad *);
179 extern uint32_t decQuadIsSubnormal(const decQuad *);
180 extern uint32_t decQuadIsZero(const decQuad *);
181 extern uint32_t decQuadRadix(const decQuad *);
182 extern uint32_t decQuadSameQuantum(const decQuad *, const decQuad *);
183 extern const char * decQuadVersion(void);
184
185 /* decNumber conversions; these are implemented as macros so as not */
186 /* to force a dependency on decimal128 and decNumber in decQuad. */
87d32bb7 187 /* decQuadFromNumber returns a decimal128 * to avoid warnings. */
f5bc1778 188 #define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn)
87d32bb7 189 #define decQuadFromNumber(dq, dn, set) decimal128FromNumber((decimal128 *)(dq), dn, set)
f5bc1778
DJ
190
191#endif
This page took 0.111625 seconds and 4 git commands to generate.