|
C++builder 2009 , win8 64bit
---------------------------------------------------
double x = -3.5;
if(x > -2.0 ) // error Invalid floating point operation ,
{
ShowMessage("x > -2.0");
}
else if (x <= -2.0 || x > -3.0 )
{
ShowMessage("test x <= -2.0 || x > -3.0");
}
else if (x >= -3.0)
{
ShowMessage("x >= -3.0");
}
어떻게 수정해야 되나요.
-----------------------------------------------------------------
#include <math.h >
#define EPSILON 0.00001
아래 함수를 이용해 봤는데 메시지가 같이 나서 어디 부분이 문제인지 알 수가 없습니다.
bool AreSame(double a, double b)
{
return fabs(a - b) < EPSILON; // Invalid floating point operation
}
//---------------------------------------------------------------------------
bool CompareDoubles2 (double A, double B)
{
double diff = A - B; // Invalid floating point operation
return (diff < EPSILON) && (-diff < EPSILON);
}
|