#include "stdafx.h"
#include <Windows.h>
int main()
{
float f = 3.1234567890123456789012345678901234567890;
double d = 3.1234567890123456789012345678901234567890;
printf("1/3 = %.20lf\n", 1.0 / 3.0);//0.33333333333333331482961625624739099293947219848633
printf("f = %f %lf %.20lf\n", f,f,f);
printf("d = %f %lf %.20lf\n", d,d,d);
//OutputDebugString输出,和printf一样的结果
char buf[255] = { 0 };
sprintf_s(buf, "f=%.20lf d=%.20lf\n", f, d);
OutputDebugString(buf);
// float是6 - 7位
// double是15 - 16位
getchar();
return 0;
}
/*
1/3 = 0.33333333333333331483 //16个3说明double 16位有效数字
f = 3.123457 3.123457 3.12345671653747558594 //float:6位有效数字,四舍五入
d = 3.123457 3.123457 3.12345678901234569125 //double:16位有效数字
*/
float是6-7位
double是15-16位