【发布时间】:2015-09-20 18:32:15
【问题描述】:
这是我的主要示例:
double hours = 35.45;
double rate = 15.00;
double tolerance = 0.01000;
cout.setf(ios::scientific);
cout << "Scientific notation: " << endl;
cout << "hours = " << hours << ", rate = " << rate << ", pay = "
<< hours * rate << ", tolerance = " << tolerance << endl << endl;
cout.setf( ios::fixed ); // if i replace but cout << fixed, it works
cout << setprecision( 3 );
cout << "Fixed decimal notation: " << endl;
cout << "hours = " << hours << ", rate = " << rate << ", pay = "
<< hours * rate << ", tolerance = " << tolerance << endl << endl;
system( "pause" );
为什么他们不相等?如果它们相等,那么这里有什么问题?
【问题讨论】:
-
你的minimal testcase在哪里?
-
这是我的最小测试用例:双小时 = 35.45; cout.setf(ios::scientific); cout.setf(ios::fixed); cout
-
....... 阅读我刚刚链接到您的页面。完全地。这不是最小的测试用例。
标签: c++ formatting cout outputstream