为什么小数位变成这样了,但直接计算不会
#include <stdio.h>
float count(int x, int t)
{
float cost = 2.3;
if(t >= 23 || t <5 )
{
cost = 2.3 * 1.2;
}
printf("cost= %f \n", cost);
if(x <= 3)
{
return 13 + 1;
}else
{
return 13 + (x-3) * cost + 1;
}
}
int main()
{
printf("%f \n", count(12, 8));
printf("%f \n", count(12, 6));
printf("%f",(13 + (12-3) * 2.3 + 1));
return 0;
}cost= 2.300000
34.699997
cost= 2.300000
34.699997
34.700000