c++ float能到小数点后多少位

时间:2023-03-09 01:42:27
c++ float能到小数点后多少位
float xiaoshu=0.0000000000000000000000000000000000000000000001;
cout<<"xiaoshu"<<xiaoshu<<endl;
double xiaoshu1=0.0000000000000000000000000000000000000000000001;
cout<<"xiaoshu1"<<xiaoshu1<<endl;

结果分别为0和11e-046

float xiaoshu=0.000000000000000000000000000000000000000000001;
cout<<"xiaoshu"<<xiaoshu<<endl;
double xiaoshu1=0.000000000000000000000000000000000000000000001;
cout<<"xiaoshu1"<<xiaoshu1<<endl;

结果分别为1.4013e-045和11e-45(前后两端代码仅差一个0)