c中的浮点数比较
2015-04-27来源:易贤网

const float CHAZHI = 0.0000001;

float a = ...;

float b = ...;

float d = a - b;

if( d > CHAZHI)

{

printf("a > b");

}

else if( d < -CHAZHI)

{

printf("a < b");

}

else if(d <= fabs(CHAZHI))

{

printf("a = b");

}

更多信息请查看IT技术专栏

推荐信息