#include<stdio.h>
void main()
{
double x,y;
float a;
x=1111111111111.111111111;
y=2222222222222.222222222;
a=x+y;
printf("%f\n",a);//輸出雙精度數時的有效位數是16
}
#include<stdio.h>
void main()
{
double x,y;
float a;
x=11111111111111111.111111111;//小數點前17個1,小數點后9個1
y=22222222222222222.222222222;
a=x+y;
printf("%f\n",a);//輸出雙精度數時的有效位數是16
}//因為輸出位數有限,果然輸出有錯誤,如果不注意數據類型,我覺得很有可能會出錯
|