warning C4244:'=' :conversion from 'double' to 'float',possible loss of data,我经常出这样的错误啊,如何判断float和double啊,#include#includeint main(){\x05float a,b,c,disc;\x05scanf("%f%f%f",&a,&b,&c);\x05disc=pow(b,2)-4*a*c;\x05printf(

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/21 09:22:20
warningC4244:''='':conversionfrom''double''to''float'',possiblelossofdata,我经常出这样的错误啊,如何判断float和double啊,#in

warning C4244:'=' :conversion from 'double' to 'float',possible loss of data,我经常出这样的错误啊,如何判断float和double啊,#include#includeint main(){\x05float a,b,c,disc;\x05scanf("%f%f%f",&a,&b,&c);\x05disc=pow(b,2)-4*a*c;\x05printf(
warning C4244:'=' :conversion from 'double' to 'float',possible loss of data,
我经常出这样的错误啊,如何判断float和double啊,
#include
#include
int main()
{
\x05float a,b,c,disc;
\x05scanf("%f%f%f",&a,&b,&c);
\x05disc=pow(b,2)-4*a*c;
\x05printf("disc=%f",disc);
\x05if(disc>0)
\x05printf("有两个不相同的实根 ");
\x05else if(disc=0)
\x05printf("有两个相同实根 ");
\x05return 0;
}

warning C4244:'=' :conversion from 'double' to 'float',possible loss of data,我经常出这样的错误啊,如何判断float和double啊,#include#includeint main(){\x05float a,b,c,disc;\x05scanf("%f%f%f",&a,&b,&c);\x05disc=pow(b,2)-4*a*c;\x05printf(
顶楼上的回答.
同时补充一点,浮点型数据最好不要用==0或者>0这样的判断,容易受到残余尾数的困扰
==0可以用ABS(disc)0什么的可以用disc>0.0000001