cout.precision(5);
数字表示小数点位数
// modify precision
#include <iostream> // std::cout, std::ios
int main () {
double f = 3.14159;
std::cout.unsetf ( std::ios::floatfield ); // floatfield not set
std::cout.precision(5);
std::cout << f << ‘\n‘;
std::cout.precision(10);
std::cout << f << ‘\n‘;
std::cout.setf( std::ios::fixed, std:: ios::floatfield ); // floatfield set to fixed
std::cout << f << ‘\n‘;
return 0;
}
原文地址:https://www.cnblogs.com/lion-zheng/p/10357785.html
时间: 2024-10-11 21:17:20