00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef INC_MI32_MATH_H
00025 #define INC_MI32_MATH_H
00026
00027 #ifndef INC_MI32_STDDEFNS_H
00028 #include <mi32/stddefns.h>
00029 #endif
00030
00031 #ifndef INC_MATH_H
00032 #include <math.h>
00033 #define INC_MATH_H
00034 #endif
00035
00036 #ifndef INC_CMATH
00037 #include <cmath>
00038 #define INC_CMATH
00039 #endif
00040
00041 #ifdef MISYSTEMDLL
00042 #define LIBEXPORT MI_DLLEXPORT
00043 #else
00044 #define LIBEXPORT MI_DLLIMPORT
00045 #endif
00046
00047
00048
00049
00050
00051 #if defined(__cplusplus)
00052 extern "C" {
00053 #endif
00054
00055 #ifndef GENERATING_DOXYGEN_OUTPUT
00056
00057 #if defined(WIN32)
00058 #if __STDC__ && _MSC_VER >= 1200
00059 #define hypot _hypot
00060 #endif
00061
00062 #elif !defined(LINUX)
00063 double hypot (double, double);
00064 #endif
00065
00066 #endif // GENERATING_DOXYGEN_OUTPUT
00067
00068
00069 LIBEXPORT double IEEE_NaN (void);
00070
00071
00072 LIBEXPORT double IEEE_Infinity (void);
00073
00074 #if defined(__cplusplus)
00075 }
00076 #endif
00077
00078 #if defined(WIN32) && defined(__cplusplus) && !defined(WIN64)
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 inline INT32 FAST_ROUND (double x) {
00096 static const double d = 1E-10;
00097 INT32 result;
00098 __asm fld x
00099 __asm fadd d
00100 __asm fistp result
00101 return result;
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111 inline INT32 FAST_CEIL (double x) {
00112 static const double d = .4999999999;
00113 INT32 result;
00114 __asm fld x
00115 __asm fadd d
00116 __asm fistp result
00117 return result;
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127 inline INT32 FAST_FLOOR (double x) {
00128 static const double d = -.4999999999;
00129 INT32 result;
00130 __asm fld x
00131 __asm fadd d
00132 __asm fistp result
00133 return result;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 inline INT32 FAST_TRUNCATE (double x) {
00146 static const double d = .4999999999;
00147 INT32 result;
00148 if (x < 0) {
00149 __asm fld x
00150 __asm fadd d
00151 __asm fistp result
00152 }
00153 else {
00154 __asm fld x
00155 __asm fsub d
00156 __asm fistp result
00157 }
00158 return result;
00159 }
00160
00161
00162 #else
00163
00164 #define FAST_ROUND(d) static_cast<INT32>(floor((d)+.5))
00165 #define FAST_CEIL(d) static_cast<INT32>(ceil(d))
00166 #define FAST_FLOOR(d) static_cast<INT32>(floor(d))
00167 #define FAST_TRUNCATE(d) static_cast<INT32>(d)
00168
00169 #endif
00170
00171 #ifndef NO_DEPRECATED
00172
00173 #define ROUND FAST_ROUND
00174 #ifdef WIN32
00175 #pragma deprecated("ROUND")
00176 #endif
00177 #endif
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 #if defined(BYTEORDER_HiLo)
00192 #if defined(SGI)
00193 #define IsNaN(x) ( (x) != (x) )
00194 #elif defined(HP_APOLLO)
00195 #define IsNaN(x) ( ( ( (UINT16*)&(x) )[0] & 0x7FFF) == 0x7FF4)
00196 #else
00197 #if defined(__cplusplus)
00198 inline bool IsNaN (double x) {return ((reinterpret_cast<UINT16*>(&x)[0] & 0x7FF8) == 0x7FF8);}
00199 #else
00200 #define IsNaN(x) ( ( ( (UINT16*)&(x) )[0] & 0x7FF8) == 0x7FF8)
00201 #endif
00202 #endif
00203 #else
00204 #if defined(__cplusplus)
00205 inline bool IsNaN (const double& x) {return ((reinterpret_cast<const UINT16*>(&x)[3] & 0x7FF8) == 0x7FF8);}
00206 #else
00207 #define IsNaN(x) ( ( ( (UINT16*)&(x) )[3] & 0x7FF8) == 0x7FF8)
00208 #endif
00209 #endif
00210
00211
00212 #ifdef BYTEORDER_HiLo
00213 #if defined(__cplusplus)
00214 inline bool IsInfPos (double x) {return ((reinterpret_cast<UINT16*>(&x)[0] & 0x7FFF) == 0x7FF0);}
00215 #else
00216 #define IsInfPos(x) ( ( ( (UINT16*)&(x) )[0] & 0x7FFF) == 0x7FF0)
00217 #endif
00218 #else
00219 #if defined(__cplusplus)
00220 inline bool IsInfPos (double x) {return ((reinterpret_cast<UINT16*>(&x)[3] & 0x7FFF) == 0x7FF0);}
00221 #else
00222 #define IsInfPos(x) ( ( ( (UINT16*)&(x) )[3] & 0x7FFF) == 0x7FF0)
00223 #endif
00224 #endif
00225
00226
00227 #ifndef NO_DEPRECATED
00228
00229 #ifndef NAN
00230
00231 #define NAN IEEE_NaN()
00232 #endif
00233
00234 #define IND IEEE_NaN()
00235 #define INF IEEE_Infinity()
00236 #define NINF (-IEEE_Infinity())
00237
00238 #ifdef WIN32
00239 #pragma deprecated("NAN")
00240 #pragma deprecated("IND")
00241 #pragma deprecated("INF")
00242 #pragma deprecated("NINF")
00243 #endif
00244
00245 #endif // NO_DEPRECATED
00246
00247
00248
00249 void ConvIEEEToVAX (
00250 double ieee_value,
00251 UINT8 *vax_value
00252 );
00253
00254
00255
00256
00257 double ConvVAXToIEEE (
00258 const UINT8 *vax_value
00259 );
00260
00261
00262
00263 #undef LIBEXPORT
00264
00265 #endif // INC_MI32_MATH_H