du512009-06-12 02:36:04
#include
#include
#include
int dengbudeng(float a, float b)
{
return memcmp(&a, &b, sizeof(float));
}
int main()
{
float a = 1.0000001;
float b = 1.0000002;
float c = 1.0000001;
if (dengbudeng(a, b) == 0)
printf("a == b\n");
else
printf("a != b\n");
if (dengbudeng(a, c) == 0)
printf("a == c\n");
else
printf("a != c\n");
return 0;
}
最简单的是用memcmp直接比