为什么浮点异常处理不能';t在Embarcadero C+工作+;64位编译中的生成器? 在64位编译< >中,我不能在AcjCabror C++ +Builder XE8中进行工作浮点异常处理。32位编译工作正常。 (MS Visual C++在32位和64位编译中都很好)
但是它不起作用。再多编写一点代码会有帮助。int_tmain(int argc,_TCHAR*argv[]){double x=exp(-100000);//应该是下溢异常wprintf(L“x=%g\n”,x);getchar();return 0;}使用您的代码,我可以确认它可以与BCC32一起工作,但不能与64位(基于叮当的)编译器一起工作。我不知道为什么。为什么浮点异常处理不能';t在Embarcadero C+工作+;64位编译中的生成器? 在64位编译< >中,我不能在AcjCabror C++ +Builder XE8中进行工作浮点异常处理。32位编译工作正常。 (MS Visual C++在32位和64位编译中都很好),c++,exception,floating-point,64-bit,c++builder,C++,Exception,Floating Point,64 Bit,C++builder,但是它不起作用。再多编写一点代码会有帮助。int_tmain(int argc,_TCHAR*argv[]){double x=exp(-100000);//应该是下溢异常wprintf(L“x=%g\n”,x);getchar();return 0;}使用您的代码,我可以确认它可以与BCC32一起工作,但不能与64位(基于叮当的)编译器一起工作。我不知道为什么。 #include <stdio.h> //wprintf #include <math.h> //exp
#include <stdio.h> //wprintf
#include <math.h> //exp
int _matherr(_exception *a) //Handles math errors; It doesn't work in x64-bit
{
printf("Error in function %s:\n", a->name);
switch (a->type)
{ case DOMAIN: wprintf(L"Argument domain error.\n"); break;
case SING: wprintf(L"Argument singularity.\n"); break;
case OVERFLOW: wprintf(L"Overflow range error.\n"); break;
case PLOSS: wprintf(L"Partial loss of significance.\n"); break;
case TLOSS: wprintf(L"Total loss of significance.\n"); break;
case UNDERFLOW: wprintf(L"The result is too small to be represented.\n"); break; //i.e. exp(-10000)
}
a->retval = 0; //Value to be returned by function
return 1;
}
int _tmain(int argc, _TCHAR* argv[])
{double x = exp(-100000); //should be UNDERFLOW exception
wprintf(L"x=%g\n", x);
getchar(); return 0;
}
Set8087CW(0x1332);
SetExceptionMask(exAllArithmeticExceptions);
SetSSEExceptionMask(exAllArithmeticExceptions);
SetFPUExceptionMask(exAllArithmeticExceptions);