直接上代码吧:
(int)x != x
bool isInt(double x)
{
long int y=(long int) x;
//if ((x-y)!=0)//这段代码可能会丢失精度
if((x-y)<=0.0000001&&(x-y)>=-0.0000001)
return true;
else
return false;
}
直接上代码吧:
(int)x != x
bool isInt(double x)
{
long int y=(long int) x;
//if ((x-y)!=0)//这段代码可能会丢失精度
if((x-y)<=0.0000001&&(x-y)>=-0.0000001)
return true;
else
return false;
}