?? prog2_08.cpp
字號:
// Program 2.8 Experimenting with floating point output
#include <iostream>
#include <iomanip>
using std::setprecision;
using std::fixed;
using std::scientific;
using std::cout;
using std::endl;
int main() {
float value1 = 0.1f;
float value2 = 2.1f;
value1 -= 0.09f; // Should be 0.01
value2 -= 2.09f; // Should be 0.01
cout << setprecision(14) << fixed; // Change to fixed notation
cout << value1 - value2 << endl; // Should output zero
cout << setprecision(5) << scientific; // Set scientific notation
cout << value1 - value2 << endl; // Should output zero
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -