//浮点异常的控制位
#define FPUEM_INVALIDOP 0x01
#define FPUEM_DENORMALOP 0x02
#define FPUEM_ZERODIVIDE 0x04
#define FPUEM_OVERFLOW 0x08
#define FPUEM_UNDERFLOW 0x10
#define FPUEM_PRECISON 0x20
#define __FORCE_INLINE__ __inline
/*----------------------------------------------------------
打开指定的浮点异常
-----------------------------------------------------------*/
__FORCE_INLINE__ static void enableFloatException(__int16 excWord = 0x000f)
{
__int16 cw;
__asm
{
not excWord
fstcw cw
mov ax , excWord
and cw , ax
fldcw cw
}
}
/*----------------------------------------------------------
关闭指定的浮点异常
-----------------------------------------------------------*/
__FORCE_INLINE__ static void disableFloatException(__int16 excWord = 0x000f)
{
__int16 cw;
__asm
{
fstcw cw
mov ax , excWord
or cw , ax
fldcw cw
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int a = 10;
float b = 0;
float c;
float pi = 3.1415926/2.0 ;
__int16 cw=0x0000;
enableFloatException();
c = a/b;
disableFloatException();
c= a/b;
return c;
}