Float和Double值在c中造成混淆

Float and Double value creating confusion in c

本文关键字:Double 值在 Float      更新时间:2023-10-16

我正在运行这个程序。但结果很奇怪。

int  main()
{
float a=.8;
if(a < .8)
    printf("a is smalln");
else
    printf("a is not smalln");
float b=.7;
if(b < .7)
    printf("b is smalln");
else
    printf("b is not smalln");
return 0;
}

它给我输出——

a不是小

b是小型

为什么不使用0.7f0.7默认为double,因此我们无法预测其行为