Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我对 GMP 库中的 MPQ 变量调用 get_d() 时,最多只能得到六位数。
C++ 应该为双打提供 8 个字节或约 15 位数字。为什么我只得到六位数?
我发现了为什么六位数是标准的-
默认情况下,当使用 cout 在 C++ 中输出双精度时,精度设置为六位有效数字。您可以通过执行以下操作来修改此精度:
double bignumber = 12.32576158213; cout << setprecision(10); cout << bignumber << endl;
输出将为 12.32576158。