数据类型
运行下面代码会出现如下警告:choosing\choosing\5.8.c(26): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据求大神解释一下是什么原因,我并没有定义double型变量啊
#include <stdio.h>
void main()
{
float b1, b2, b4, b6, b10,d;
long int i;
int c;
b1 = 100000 * 0.1;
b2 = b1 + 100000*0.075;
b4 = b2 + 200000*0.05;
b6 = b4 + 200000*0.03;
b10 = b6 + 400000*0.015;
scanf_s("%ld", &i);
if (i >1000000)c = 10;
else c = i / 100000;
switch(c)
{
case 0:d = i*0.1; break;
case 1:d = b1 + (i - 100000)*0.075; break;
case 2:
case 3:d = b2 + (i - 200000)*0.05; break;
case 4:
case 5:d = b4 + (i - 400000)*0.03; break;
case 6:
case 7:
case 8:
case 9:d = b6 + (i - 600000)*0.015; break;
case 10:d = b10 + (i - 1000000)*0.01; break;
}
printf("%5.2f", d);
}