float.h

00001 /*  wcecompat: Windows CE C Runtime Library "compatibility" library.
00002  *
00003  *  Copyright (C) 2001-2002 Essemer Pty Ltd.  All rights reserved.
00004  *  http://www.essemer.com.au/
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 #ifndef __wcecompat__FLOAT_H__
00023 #define __wcecompat__FLOAT_H__
00024 
00025 #include "stddef.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 #define DBL_DIG        15            /* # of decimal digits of precision */
00032 #define DBL_EPSILON    2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
00033 #define DBL_MANT_DIG   53            /* # of bits in mantissa */
00034 #define DBL_MAX        1.7976931348623158e+308 /* max value */
00035 #define DBL_MAX_10_EXP 308            /* max decimal exponent */
00036 #define DBL_MAX_EXP    1024            /* max binary exponent */
00037 #define DBL_MIN        2.2250738585072014e-308 /* min positive value */
00038 #define DBL_MIN_10_EXP (-307)            /* min decimal exponent */
00039 #define DBL_MIN_EXP    (-1021)         /* min binary exponent */
00040 #define _DBL_RADIX     2            /* exponent radix */
00041 #define _DBL_ROUNDS    1            /* addition rounding: near */
00042 
00043 #define FLT_DIG        6            /* # of decimal digits of precision */
00044 #define FLT_EPSILON    1.192092896e-07F    /* smallest such that 1.0+FLT_EPSILON != 1.0 */
00045 #define FLT_GUARD      0
00046 #define FLT_MANT_DIG   24            /* # of bits in mantissa */
00047 #define FLT_MAX        3.402823466e+38F    /* max value */
00048 #define FLT_MAX_10_EXP 38            /* max decimal exponent */
00049 #define FLT_MAX_EXP    128            /* max binary exponent */
00050 #define FLT_MIN        1.175494351e-38F    /* min positive value */
00051 #define FLT_MIN_10_EXP (-37)            /* min decimal exponent */
00052 #define FLT_MIN_EXP    (-125)            /* min binary exponent */
00053 #define FLT_NORMALIZE  0
00054 #define FLT_RADIX      2            /* exponent radix */
00055 #define FLT_ROUNDS     1            /* addition rounding: near */
00056 
00057 #define LDBL_DIG        DBL_DIG         /* # of decimal digits of precision */
00058 #define LDBL_EPSILON    DBL_EPSILON        /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
00059 #define LDBL_MANT_DIG   DBL_MANT_DIG        /* # of bits in mantissa */
00060 #define LDBL_MAX        DBL_MAX         /* max value */
00061 #define LDBL_MAX_10_EXP DBL_MAX_10_EXP        /* max decimal exponent */
00062 #define LDBL_MAX_EXP    DBL_MAX_EXP        /* max binary exponent */
00063 #define LDBL_MIN        DBL_MIN         /* min positive value */
00064 #define LDBL_MIN_10_EXP DBL_MIN_10_EXP        /* min decimal exponent */
00065 #define LDBL_MIN_EXP    DBL_MIN_EXP        /* min binary exponent */
00066 #define _LDBL_RADIX     DBL_RADIX        /* exponent radix */
00067 #define _LDBL_ROUNDS    DBL_ROUNDS        /* addition rounding: near */
00068 
00069 // Abstract User Control Word Mask and bit definitions
00070 #define _MCW_EM         0x0008001f        /* interrupt Exception Masks */
00071 #define _EM_INEXACT     0x00000001        /*   inexact (precision) */
00072 #define _EM_UNDERFLOW   0x00000002        /*   underflow */
00073 #define _EM_OVERFLOW    0x00000004        /*   overflow */
00074 #define _EM_ZERODIVIDE  0x00000008        /*   zero divide */
00075 #define _EM_INVALID     0x00000010        /*   invalid */
00076 #define _MCW_RC         0x00000300        /* Rounding Control */
00077 #define _RC_NEAR        0x00000000        /*   near */
00078 #define _RC_DOWN        0x00000100        /*   down */
00079 #define _RC_UP          0x00000200        /*   up */
00080 #define _RC_CHOP        0x00000300        /*   chop */
00081 
00082 // Abstract User Status Word bit definitions
00083 #define _SW_INEXACT     0x00000001        /* inexact (precision) */
00084 #define _SW_UNDERFLOW   0x00000002        /* underflow */
00085 #define _SW_OVERFLOW    0x00000004        /* overflow */
00086 #define _SW_ZERODIVIDE  0x00000008        /* zero divide */
00087 #define _SW_INVALID     0x00000010        /* invalid */
00088 
00089 #if ! defined (_M_CEE)
00090 
00091 // i386 specific definitions
00092 #define _MCW_PC       0x00030000        /* Precision Control */
00093 #define _PC_64        0x00000000        /*    64 bits */
00094 #define _PC_53        0x00010000        /*    53 bits */
00095 #define _PC_24        0x00020000        /*    24 bits */
00096 #define _MCW_IC       0x00040000        /* Infinity Control */
00097 #define _IC_AFFINE    0x00040000        /*   affine */
00098 #define _IC_PROJECTIVE  0x00000000        /*   projective */
00099 #define _EM_DENORMAL    0x00080000        /* denormal exception mask (_control87 only) */
00100 #define _SW_DENORMAL    0x00080000        /* denormal status bit */
00101 
00102 // MIPS R4000 and SH4 specific definitions
00103 #ifdef  _M_SH
00104 #define _MCW_DN     0x00040000      /* Denormal Control (SH4)   */
00105 #define _DN_FLUSH   0x00040000      /*   flush to zero (SH4)    */
00106 #else
00107 #define _MCW_DN     0x01000000      /* Denormal Control (R4000) */
00108 #define _DN_FLUSH   0x01000000      /*   flush to zero (R4000)  */
00109 #endif
00110 #define _DN_SAVE    0x00000000        /*   save */
00111 
00112 
00113 // initial Control Word value
00114 #ifdef    _M_IX86
00115 #define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT )
00116 #else
00117 #define _CW_DEFAULT ( _RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT )
00118 #endif
00119 #endif  // ! _M_CEE
00120 
00121 // invalid subconditions (_SW_INVALID also set)
00122 #define _SW_UNEMULATED      0x0040    /* unemulated instruction */
00123 #define _SW_SQRTNEG         0x0080    /* square root of a neg number */
00124 #define _SW_STACKOVERFLOW   0x0200    /* FP stack overflow */
00125 #define _SW_STACKUNDERFLOW  0x0400    /* FP stack underflow */
00126 
00127 //  Floating point error signals and return codes
00128 #define _FPE_INVALID        0x81
00129 #define _FPE_DENORMAL       0x82
00130 #define _FPE_ZERODIVIDE     0x83
00131 #define _FPE_OVERFLOW       0x84
00132 #define _FPE_UNDERFLOW      0x85
00133 #define _FPE_INEXACT        0x86
00134 #define _FPE_UNEMULATED     0x87
00135 #define _FPE_SQRTNEG        0x88
00136 #define _FPE_STACKOVERFLOW  0x8a
00137 #define _FPE_STACKUNDERFLOW 0x8b
00138 #define _FPE_EXPLICITGEN    0x8c    /* raise( SIGFPE ); */
00139 
00140 // Floating point function prototypes
00141 unsigned int __cdecl _clearfp(void);
00142 unsigned int __cdecl _controlfp(unsigned int,unsigned int);
00143 unsigned int __cdecl _statusfp(void);
00144 void         __cdecl _fpreset(void);
00145 #define _clear87    _clearfp
00146 #define _status87   _statusfp
00147 
00148 // IEEE recommended functions
00149 double __cdecl _copysign (double, double);
00150 double __cdecl _chgsign (double);
00151 double __cdecl _scalb(double, long);
00152 double __cdecl _logb(double);
00153 double __cdecl _nextafter(double, double);
00154 int    __cdecl _finite(double);
00155 int    __cdecl _isnan(double);
00156 int    __cdecl _fpclass(double);
00157 
00158 #define _FPCLASS_SNAN    0x0001    /* signaling NaN */
00159 #define _FPCLASS_QNAN    0x0002    /* quiet NaN */
00160 #define _FPCLASS_NINF    0x0004    /* negative infinity */
00161 #define _FPCLASS_NN    0x0008    /* negative normal */
00162 #define _FPCLASS_ND    0x0010    /* negative denormal */
00163 #define _FPCLASS_NZ    0x0020    /* -0 */
00164 #define _FPCLASS_PZ    0x0040    /* +0 */
00165 #define _FPCLASS_PD    0x0080    /* positive denormal */
00166 #define _FPCLASS_PN    0x0100    /* positive normal */
00167 #define _FPCLASS_PINF    0x0200    /* positive infinity */
00168 
00169 typedef float _FP32;
00170 typedef double _FP64;
00171 typedef short _I16;
00172 typedef int _I32;
00173 typedef unsigned short _U16;
00174 typedef unsigned int _U32;
00175 
00176 typedef struct {
00177     unsigned long W[4];
00178 } _U32ARRAY;
00179 
00180 typedef struct {
00181     unsigned short W[5];
00182 } _FP80;
00183 
00184 typedef struct {
00185     unsigned long W[4];
00186 } _FP128;
00187 
00188 typedef struct {
00189     unsigned long W[2];
00190 } _I64;
00191 
00192 typedef struct {
00193     unsigned long W[2];
00194 } _U64;
00195 
00196 typedef struct {
00197     unsigned short W[5];
00198 } _BCD80;
00199 
00200 typedef struct {
00201     union {
00202         _FP32        Fp32Value;
00203         _FP64        Fp64Value;
00204         _FP80        Fp80Value;
00205         _FP128       Fp128Value;
00206         _I16         I16Value;
00207         _I32         I32Value;
00208         _I64         I64Value;
00209         _U16         U16Value;
00210         _U32         U32Value;
00211         _U64         U64Value;
00212         _BCD80       Bcd80Value;
00213         char         *StringValue;
00214         int      CompareValue;
00215         _U32ARRAY    U32ArrayValue;
00216     } Value;
00217     unsigned int OperandValid : 1;
00218     unsigned int Format : 4;
00219 } _FPIEEE_VALUE;
00220 
00221 typedef struct {
00222     unsigned int Inexact : 1;
00223     unsigned int Underflow : 1;
00224     unsigned int Overflow : 1;
00225     unsigned int ZeroDivide : 1;
00226     unsigned int InvalidOperation : 1;
00227 } _FPIEEE_EXCEPTION_FLAGS;
00228 
00229 typedef struct {
00230     unsigned int RoundingMode : 2;
00231     unsigned int Precision : 3;
00232     unsigned int Operation :12;
00233     _FPIEEE_EXCEPTION_FLAGS Cause;
00234     _FPIEEE_EXCEPTION_FLAGS Enable;
00235     _FPIEEE_EXCEPTION_FLAGS Status;
00236     _FPIEEE_VALUE Operand1;
00237     _FPIEEE_VALUE Operand2;
00238     _FPIEEE_VALUE Result;
00239 } _FPIEEE_RECORD;
00240 
00241 typedef struct _EXCEPTION_POINTERS *PEXCEPTION_POINTERS;
00242 
00243 #ifdef _WIN32_WCE_EMULATION
00244 int __cdecl _fpieee_flt(unsigned long exc_code, PEXCEPTION_POINTERS p, int handler(_FPIEEE_RECORD *));
00245 #else
00246 int _fpieee_flt(unsigned long exc_code, PEXCEPTION_POINTERS p, int handler(_FPIEEE_RECORD *));
00247 #endif
00248 
00249 // Non-ANSI names for compatibility
00250 #define DBL_RADIX        _DBL_RADIX
00251 #define DBL_ROUNDS       _DBL_ROUNDS
00252 #define LDBL_RADIX       _LDBL_RADIX
00253 #define LDBL_ROUNDS      _LDBL_ROUNDS
00254 #define MCW_EM           _MCW_EM
00255 #define EM_INVALID       _EM_INVALID
00256 #define EM_ZERODIVIDE    _EM_ZERODIVIDE
00257 #define EM_OVERFLOW      _EM_OVERFLOW
00258 #define EM_UNDERFLOW     _EM_UNDERFLOW
00259 #define EM_INEXACT       _EM_INEXACT
00260 
00261 #if ! defined (_M_CEE)
00262 
00263 #define EM_DENORMAL      _EM_DENORMAL
00264 #define SW_DENORMAL      _SW_DENORMAL
00265 #define MCW_IC           _MCW_IC
00266 #define IC_AFFINE        _IC_AFFINE
00267 #define IC_PROJECTIVE    _IC_PROJECTIVE
00268 #define MCW_PC           _MCW_PC
00269 #define PC_24            _PC_24
00270 #define PC_53            _PC_53
00271 #define PC_64            _PC_64
00272 
00273 #endif // ! _M_CEE
00274 
00275 #define MCW_RC           _MCW_RC
00276 #define RC_CHOP          _RC_CHOP
00277 #define RC_UP            _RC_UP
00278 #define RC_DOWN          _RC_DOWN
00279 #define RC_NEAR          _RC_NEAR
00280 #define CW_DEFAULT       _CW_DEFAULT
00281 #define SW_INVALID       _SW_INVALID
00282 #define SW_ZERODIVIDE    _SW_ZERODIVIDE
00283 #define SW_OVERFLOW      _SW_OVERFLOW
00284 #define SW_UNDERFLOW     _SW_UNDERFLOW
00285 #define SW_INEXACT       _SW_INEXACT
00286 #define SW_UNEMULATED    _SW_UNEMULATED
00287 #define SW_SQRTNEG       _SW_SQRTNEG
00288 #define SW_STACKOVERFLOW   _SW_STACKOVERFLOW
00289 #define SW_STACKUNDERFLOW  _SW_STACKUNDERFLOW
00290 #define FPE_INVALID        _FPE_INVALID
00291 #define FPE_DENORMAL     _FPE_DENORMAL
00292 #define FPE_ZERODIVIDE   _FPE_ZERODIVIDE
00293 #define FPE_OVERFLOW     _FPE_OVERFLOW
00294 #define FPE_UNDERFLOW    _FPE_UNDERFLOW
00295 #define FPE_INEXACT      _FPE_INEXACT
00296 #define FPE_UNEMULATED   _FPE_UNEMULATED
00297 #define FPE_SQRTNEG        _FPE_SQRTNEG
00298 #define FPE_STACKOVERFLOW  _FPE_STACKOVERFLOW
00299 #define FPE_STACKUNDERFLOW _FPE_STACKUNDERFLOW
00300 #define FPE_EXPLICITGEN    _FPE_EXPLICITGEN
00301 
00302 #ifdef _WIN32_WCE_EMULATION
00303 double __cdecl _frnd(double);
00304 double __cdecl _fsqrt(double);
00305 #else
00306 double _frnd(double);
00307 double _fsqrt(double);
00308 #endif
00309 
00310 // definition of a _complex struct to be used by those who use cabs and
00311 // want type checking on their argument
00312 struct _complex {
00313     double x,y;    /* real and imaginary parts */
00314     } ;
00315 
00316 // Non-ANSI name for compatibility
00317 #define complex _complex
00318 
00319 // definitions of _HUGE and HUGE_VAL - respectively the XENIX and ANSI names
00320 // for a value returned in case of error by a number of the floating point
00321 // math routines
00322 _CRTIMP
00323 extern double _HUGE;
00324 #define HUGE_VAL _HUGE
00325 
00326 #ifdef __cplusplus
00327 }
00328 #endif
00329 
00330 #endif /* __wcecompat__FLOAT_H__ */

Generated on Mon Jun 5 10:20:48 2006 for Intelligence.kdevelop by  doxygen 1.4.6