浮点型常量_#include

浮点型常量_浮点数_02

用有效数字位来比较浮点数

#include <stdio.h>

int main()
{
    float b = 1.456;
    if(b-1.456 > -0.000001 && b-1.456<0.000001)
        printf("b is equal to 1.456\n");
    else
        printf("f is not equal to 1.456\n");                                                                               
    return 0;
}