double fat = 0.2654654645486684646846865584656566554566556564654654899866223625564668186456564564664564;
cout<<fat<<endl;
结果:
0.265465
是否应该再长 7 个字符?我以为一个双人可以容纳更多?
我也得到了“long double”的相同结果。
最佳答案
您只是看到 iostream
使用的默认精度。
要改善事物,请使用 std::setprecision()
.
const int max_digits = std::numeric_limits<double>::digits10;
std::cout << std::setprecision(max_digits) << fat << std::endl;
关于c++ - 在输出的 7 个字符处双截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10996899/