STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Functions
fenv.h File Reference
#include <float.h>

Go to the source code of this file.

Classes

struct  fenv_t
 

Macros

#define _FENV
 
#define FE_INEXACT   _SW_INEXACT /* _EM_INEXACT 0x00000001 inexact (precision) */
 
#define FE_UNDERFLOW   _SW_UNDERFLOW /* _EM_UNDERFLOW 0x00000002 underflow */
 
#define FE_OVERFLOW   _SW_OVERFLOW /* _EM_OVERFLOW 0x00000004 overflow */
 
#define FE_DIVBYZERO   _SW_ZERODIVIDE /* _EM_ZERODIVIDE 0x00000008 zero divide */
 
#define FE_INVALID   _SW_INVALID /* _EM_INVALID 0x00000010 invalid */
 
#define FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
 
#define FE_DFL_ENV   (&_Fenv0)
 
#define FE_TONEAREST   0x0000
 
#define FE_UPWARD   0x0100
 
#define FE_DOWNWARD   0x0200
 
#define FE_TOWARDZERO   0x0300
 
#define FE_ROUND_MASK   0x0300
 
#define __DBL_BIG   1e+300 /* may raise inexact too */
 

Typedefs

typedef unsigned long fexcept_t
 
typedef struct fenv_t fenv_t
 

Functions

_CRTIMP int __cdecl fegetenv (_Inout_ fenv_t *)
 
_CRTIMP int __cdecl fesetenv (_In_ const fenv_t *)
 
_CRTIMP int __cdecl feclearexcept (_In_ int)
 
_CRTIMP int __cdecl feholdexcept (_Inout_ fenv_t *)
 
_CRTIMP int __cdecl fetestexcept (_In_ int)
 
_CRTIMP int __cdecl fegetexceptflag (_Inout_ fexcept_t *, _In_ int)
 
_CRTIMP int __cdecl fesetexceptflag (_In_ const fexcept_t *, _In_ int)
 
 __declspec (selectany) extern const fenv_t _Fenv0
 
_CRTIMP int __cdecl fegetround (void)
 
_CRTIMP int __cdecl fesetround (_In_ int)
 
__inline int __CRTDECL feraiseexcept (_In_ int _Except)
 
__inline int __CRTDECL feupdateenv (_In_ const fenv_t *_Penv)
 

Macro Definition Documentation

#define __DBL_BIG   1e+300 /* may raise inexact too */
#define _FENV
#define FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
#define FE_DFL_ENV   (&_Fenv0)
#define FE_DIVBYZERO   _SW_ZERODIVIDE /* _EM_ZERODIVIDE 0x00000008 zero divide */
#define FE_DOWNWARD   0x0200
#define FE_INEXACT   _SW_INEXACT /* _EM_INEXACT 0x00000001 inexact (precision) */
#define FE_INVALID   _SW_INVALID /* _EM_INVALID 0x00000010 invalid */
#define FE_OVERFLOW   _SW_OVERFLOW /* _EM_OVERFLOW 0x00000004 overflow */
#define FE_ROUND_MASK   0x0300
#define FE_TONEAREST   0x0000
#define FE_TOWARDZERO   0x0300
#define FE_UNDERFLOW   _SW_UNDERFLOW /* _EM_UNDERFLOW 0x00000002 underflow */
#define FE_UPWARD   0x0100

Typedef Documentation

typedef struct fenv_t fenv_t
typedef unsigned long fexcept_t

Function Documentation

__declspec ( selectany  ) const
_CRTIMP int __cdecl feclearexcept ( _In_  int)
_CRTIMP int __cdecl fegetenv ( _Inout_ fenv_t )
_CRTIMP int __cdecl fegetexceptflag ( _Inout_ fexcept_t ,
_In_  int 
)
_CRTIMP int __cdecl fegetround ( void  )
_CRTIMP int __cdecl feholdexcept ( _Inout_ fenv_t )
__inline int __CRTDECL feraiseexcept ( _In_ int  _Except)
81 {
82  #define __DBL_BIG 1e+300 /* may raise inexact too */
83 
84  static struct
85  {
86  int _Except_Val;
87  double _Num, _Denom;
88  } const _Table[] =
89  { /* raise exception by evaluating num / denom */
90  {FE_INVALID, 0.0, 0.0},
91  {FE_DIVBYZERO, 1.0, 0.0},
92  {FE_OVERFLOW, __DBL_BIG, 1.0 / __DBL_BIG},
94  {FE_INEXACT, 2.0, 3.0}
95  };
96 
97  fexcept_t _Flags = 0;
98  double _Ans = 0.0;
99  int _N;
100 
101  if ((_Except &= FE_ALL_EXCEPT) == 0)
102  {
103  return 0;
104  }
105 
106  /* get the current status flags */
107  fegetexceptflag(&_Flags, FE_ALL_EXCEPT);
108 
109  _Except &= ~_Flags;
110  _Flags |= _Except;
111 
112  /* set the new status flags */
113  fesetexceptflag(&_Flags, FE_ALL_EXCEPT);
114 
115  /* raise the exceptions not masked */
116  for (_N = 0; _N < sizeof(_Table) / sizeof(_Table[0]); ++_N)
117  {
118  if ((_Except & _Table[_N]._Except_Val) != 0)
119  {
120  _Ans = _Table[_N]._Num / _Table[_N]._Denom;
121  }
122  }
123 
124  return 0;
125 }
_CRTIMP int __cdecl fegetexceptflag(_Inout_ fexcept_t *, _In_ int)
#define FE_OVERFLOW
Definition: fenv.h:41
#define FE_DIVBYZERO
Definition: fenv.h:42
_N
Definition: wchar.h:1269
#define FE_UNDERFLOW
Definition: fenv.h:40
#define FE_INVALID
Definition: fenv.h:43
_CRTIMP int __cdecl fesetexceptflag(_In_ const fexcept_t *, _In_ int)
#define FE_ALL_EXCEPT
Definition: fenv.h:45
#define FE_INEXACT
Definition: fenv.h:39
#define __DBL_BIG
unsigned long fexcept_t
Definition: fenv.h:33
_CRTIMP int __cdecl fesetenv ( _In_ const fenv_t )
_CRTIMP int __cdecl fesetexceptflag ( _In_ const fexcept_t ,
_In_  int 
)
_CRTIMP int __cdecl fesetround ( _In_  int)
_CRTIMP int __cdecl fetestexcept ( _In_  int)
__inline int __CRTDECL feupdateenv ( _In_ const fenv_t _Penv)
128 {
129  int _Except = fetestexcept(FE_ALL_EXCEPT);
130 
131  if (fesetenv(_Penv) != 0 || feraiseexcept(_Except) != 0)
132  {
133  return 1;
134  }
135 
136  return 0;
137 }
_CRTIMP int __cdecl fesetenv(_In_ const fenv_t *)
__inline int __CRTDECL feraiseexcept(_In_ int _Except)
Definition: fenv.h:80
#define FE_ALL_EXCEPT
Definition: fenv.h:45
_CRTIMP int __cdecl fetestexcept(_In_ int)