GMP 被破坏了吗?这是做不到的!

发布于 2024-08-24 01:13:22 字数 100 浏览 3 评论 0原文

当我对 GMP 库中的 MPQ 变量调用 get_d() 时,我最多只能得到六位数字。

C++ 应该为双精度数提供 8 个字节或约 15 位数字。为什么我只得到六位数?

When I call get_d() on a MPQ variable in the GMP library, I only get at most six digits.

C++ is supposed to provide 8 bytes or ~15 digits for doubles. Why am I only getting six digits?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2024-08-31 01:13:22

我发现了为什么六位数字是标准的 -

默认情况下,当使用 cout 在 C++ 中输出双精度数时,精度设置为六位有效数字。您可以通过执行以下操作来修改此精度:

double bignumber = 12.32576158213;
cout << setprecision(10);
cout << bignumber << endl;

输出将为 12.32576158。

I found out why six digits was standard -

by default, when outputting doubles in C++ using cout, the precision is set to six significant figures. You can modify this precision by doing the following:

double bignumber = 12.32576158213;
cout << setprecision(10);
cout << bignumber << endl;

The output will be 12.32576158.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文