00001
00024 #ifndef _EPD
00025 #define _EPD
00026
00027
00028
00029
00030
00031
00032 #define EPD_MAX_BIN 1023
00033 #define EPD_MAX_DEC 308
00034 #define EPD_EXP_INF 0x7ff
00035
00036
00037
00038
00039
00049 #ifdef EPD_BIG_ENDIAN
00050 struct IeeeDoubleStruct {
00051 unsigned int sign: 1;
00052 unsigned int exponent: 11;
00053 unsigned int mantissa0: 20;
00054 unsigned int mantissa1: 32;
00055 };
00056 #else
00057 struct IeeeDoubleStruct {
00058 unsigned int mantissa1: 32;
00059 unsigned int mantissa0: 20;
00060 unsigned int exponent: 11;
00061 unsigned int sign: 1;
00062 };
00063 #endif
00064
00074 #ifdef EPD_BIG_ENDIAN
00075 struct IeeeNanStruct {
00076 unsigned int sign: 1;
00077 unsigned int exponent: 11;
00078 unsigned int quiet_bit: 1;
00079 unsigned int mantissa0: 19;
00080 unsigned int mantissa1: 32;
00081 };
00082 #else
00083 struct IeeeNanStruct {
00084 unsigned int mantissa1: 32;
00085 unsigned int mantissa0: 19;
00086 unsigned int quiet_bit: 1;
00087 unsigned int exponent: 11;
00088 unsigned int sign: 1;
00089 };
00090 #endif
00091
00101 struct EpDoubleStruct {
00102 union {
00103 double value;
00104 struct IeeeDoubleStruct bits;
00105 struct IeeeNanStruct nan;
00106 } type;
00107 int exponent;
00108 };
00109
00110
00111
00112
00113 typedef struct EpDoubleStruct EpDouble;
00114 typedef struct IeeeDoubleStruct IeeeDouble;
00115 typedef struct IeeeNanStruct IeeeNan;
00116
00117
00118
00119
00120
00121
00122 EpDouble *EpdAlloc();
00123 int EpdCmp(const char *key1, const char *key2);
00124 void EpdFree(EpDouble *epd);
00125 void EpdGetString(EpDouble *epd, char *str);
00126 void EpdConvert(double value, EpDouble *epd);
00127 void EpdMultiply(EpDouble *epd1, double value);
00128 void EpdMultiply2(EpDouble *epd1, EpDouble *epd2);
00129 void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2);
00130 void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
00131 void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
00132 void EpdDivide(EpDouble *epd1, double value);
00133 void EpdDivide2(EpDouble *epd1, EpDouble *epd2);
00134 void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
00135 void EpdAdd(EpDouble *epd1, double value);
00136 void EpdAdd2(EpDouble *epd1, EpDouble *epd2);
00137 void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
00138 void EpdSubtract(EpDouble *epd1, double value);
00139 void EpdSubtract2(EpDouble *epd1, EpDouble *epd2);
00140 void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
00141 void EpdPow2(int n, EpDouble *epd);
00142 void EpdPow2Decimal(int n, EpDouble *epd);
00143 void EpdNormalize(EpDouble *epd);
00144 void EpdNormalizeDecimal(EpDouble *epd);
00145 void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent);
00146 int EpdGetExponent(double value);
00147 int EpdGetExponentDecimal(double value);
00148 void EpdMakeInf(EpDouble *epd, int sign);
00149 void EpdMakeZero(EpDouble *epd, int sign);
00150 void EpdMakeNan(EpDouble *epd);
00151 void EpdCopy(EpDouble *from, EpDouble *to);
00152 int EpdIsInf(EpDouble *epd);
00153 int EpdIsZero(EpDouble *epd);
00154 int EpdIsNan(EpDouble *epd);
00155 int EpdIsNanOrInf(EpDouble *epd);
00156 int IsInfDouble(double value);
00157 int IsNanDouble(double value);
00158 int IsNanOrInfDouble(double value);
00159
00160 #endif