为何visual studio 2008 输出的double类型只有6位有效数字
测试代码如下:#include<iostream>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
int exponent = 0;
double base = 0.0;
double result = 1.0;
cout << "Enter base and exponent: ";
cin >> base >> exponent;
for (int i = 0; i < exponent; ++i)
{
result *= base;
}
cout << "The result is " << result <<endl;
return 0;
}
测试数据:
(1)base = 12.34, exponent = 5;
(2) base = 2.537, exponent = 3;
(3) base = 12.34, exponent = 6;
输出结果:
(1)result = 286138;
(2) result = 16.3291;
(3) result = 3.53095e006;
只有添加显示精度位数是才能显示,不知是软件设置问题,还是就只能显示6位精度。我在win7和winxp下的visual studio 2008软件测试都是一样的结果。那位知道问题所在的,烦请帮我解决疑惑。