emergency commit
[cl-cudd.git] / distr / epd / epd.h
blob4b538c016a8451f6409281701de1d1e80068595e
1 /**CHeaderFile*****************************************************************
3 FileName [epd.h]
5 PackageName [epd]
7 Synopsis [The University of Colorado extended double precision package.]
9 Description [arithmetic functions with extended double precision.]
11 SeeAlso []
13 Author [In-Ho Moon]
15 Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
17 All rights reserved.
19 Redistribution and use in source and binary forms, with or without
20 modification, are permitted provided that the following conditions
21 are met:
23 Redistributions of source code must retain the above copyright
24 notice, this list of conditions and the following disclaimer.
26 Redistributions in binary form must reproduce the above copyright
27 notice, this list of conditions and the following disclaimer in the
28 documentation and/or other materials provided with the distribution.
30 Neither the name of the University of Colorado nor the names of its
31 contributors may be used to endorse or promote products derived from
32 this software without specific prior written permission.
34 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
37 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
38 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
40 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
44 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 POSSIBILITY OF SUCH DAMAGE.]
47 Revision [$Id: epd.h,v 1.9 2004/08/13 18:20:30 fabio Exp $]
49 ******************************************************************************/
51 #ifndef _EPD
52 #define _EPD
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
58 /*---------------------------------------------------------------------------*/
59 /* Constant declarations */
60 /*---------------------------------------------------------------------------*/
62 #define EPD_MAX_BIN 1023
63 #define EPD_MAX_DEC 308
64 #define EPD_EXP_INF 0x7ff
66 /*---------------------------------------------------------------------------*/
67 /* Structure declarations */
68 /*---------------------------------------------------------------------------*/
70 /**Struct**********************************************************************
72 Synopsis [IEEE double struct.]
74 Description [IEEE double struct.]
76 SeeAlso []
78 ******************************************************************************/
79 #ifdef EPD_BIG_ENDIAN
80 struct IeeeDoubleStruct { /* BIG_ENDIAN */
81 unsigned int sign: 1;
82 unsigned int exponent: 11;
83 unsigned int mantissa0: 20;
84 unsigned int mantissa1: 32;
86 #else
87 struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
88 unsigned int mantissa1: 32;
89 unsigned int mantissa0: 20;
90 unsigned int exponent: 11;
91 unsigned int sign: 1;
93 #endif
95 /**Struct**********************************************************************
97 Synopsis [IEEE double NaN struct.]
99 Description [IEEE double NaN struct.]
101 SeeAlso []
103 ******************************************************************************/
104 #ifdef EPD_BIG_ENDIAN
105 struct IeeeNanStruct { /* BIG_ENDIAN */
106 unsigned int sign: 1;
107 unsigned int exponent: 11;
108 unsigned int quiet_bit: 1;
109 unsigned int mantissa0: 19;
110 unsigned int mantissa1: 32;
112 #else
113 struct IeeeNanStruct { /* LITTLE_ENDIAN */
114 unsigned int mantissa1: 32;
115 unsigned int mantissa0: 19;
116 unsigned int quiet_bit: 1;
117 unsigned int exponent: 11;
118 unsigned int sign: 1;
120 #endif
122 /**Struct**********************************************************************
124 Synopsis [Extended precision double to keep very large value.]
126 Description [Extended precision double to keep very large value.]
128 SeeAlso []
130 ******************************************************************************/
131 union EpTypeUnion {
132 double value;
133 struct IeeeDoubleStruct bits;
134 struct IeeeNanStruct nan;
137 struct EpDoubleStruct {
138 union EpTypeUnion type;
139 int exponent;
142 /*---------------------------------------------------------------------------*/
143 /* Type declarations */
144 /*---------------------------------------------------------------------------*/
145 typedef struct EpDoubleStruct EpDouble;
146 typedef struct IeeeDoubleStruct IeeeDouble;
147 typedef struct IeeeNanStruct IeeeNan;
148 typedef union EpTypeUnion EpType;
150 /**AutomaticStart*************************************************************/
152 /*---------------------------------------------------------------------------*/
153 /* Function prototypes */
154 /*---------------------------------------------------------------------------*/
156 extern EpDouble *EpdAlloc(void);
157 extern int EpdCmp(const char *key1, const char *key2);
158 extern void EpdFree(EpDouble *epd);
159 extern void EpdGetString(EpDouble *epd, char *str);
160 extern void EpdConvert(double value, EpDouble *epd);
161 extern void EpdMultiply(EpDouble *epd1, double value);
162 extern void EpdMultiply2(EpDouble *epd1, EpDouble *epd2);
163 extern void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2);
164 extern void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
165 extern void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
166 extern void EpdDivide(EpDouble *epd1, double value);
167 extern void EpdDivide2(EpDouble *epd1, EpDouble *epd2);
168 extern void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
169 extern void EpdAdd(EpDouble *epd1, double value);
170 extern void EpdAdd2(EpDouble *epd1, EpDouble *epd2);
171 extern void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
172 extern void EpdSubtract(EpDouble *epd1, double value);
173 extern void EpdSubtract2(EpDouble *epd1, EpDouble *epd2);
174 extern void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
175 extern void EpdPow2(int n, EpDouble *epd);
176 extern void EpdPow2Decimal(int n, EpDouble *epd);
177 extern void EpdNormalize(EpDouble *epd);
178 extern void EpdNormalizeDecimal(EpDouble *epd);
179 extern void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent);
180 extern int EpdGetExponent(double value);
181 extern int EpdGetExponentDecimal(double value);
182 extern void EpdMakeInf(EpDouble *epd, int sign);
183 extern void EpdMakeZero(EpDouble *epd, int sign);
184 extern void EpdMakeNan(EpDouble *epd);
185 extern void EpdCopy(EpDouble *from, EpDouble *to);
186 extern int EpdIsInf(EpDouble *epd);
187 extern int EpdIsZero(EpDouble *epd);
188 extern int EpdIsNan(EpDouble *epd);
189 extern int EpdIsNanOrInf(EpDouble *epd);
190 extern int IsInfDouble(double value);
191 extern int IsNanDouble(double value);
192 extern int IsNanOrInfDouble(double value);
194 /**AutomaticEnd***************************************************************/
196 #ifdef __cplusplus
198 #endif
200 #endif /* _EPD */