给定精度下的 gmp 浮点下限

发布于 2025-01-08 19:15:56 字数 235 浏览 3 评论 0原文

我正在编写一个带有 GMP 及其任意精度浮点数的 C 库。我需要砍掉“小数字”,但我不知道如何确定什么是小数字。

假设我将 GMP 浮点 (mpf_t) 的精度设置为 n 位。那么在计算中什么才算小呢?

对于任何熟悉 GSL(GNU 科学库)的人来说,我需要相当于 GSL_DBL_EPSILON 的值,在我的 32 位计算机上,双精度值恰好是 2.2204460492503131e-16。

提前致谢,j。

I'm writing a C library with GMP and its arbitrary precision floats. I need to chop off "small numbers", but I don't know how to determine what is small.

Say I set the precision of GMP floats (mpf_t) to n bit. Then what is to be considered small in the calculation?

For any of you who might be familiar with GSL (GNU Scientific Library), I need the equivalent of their GSL_DBL_EPSILON, which for double, on my 32-bit computer, happpens to be 2.2204460492503131e-16.

Thanks in advance,j.

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

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

发布评论

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

评论(1

ヤ经典坏疍 2025-01-15 19:15:56

我想我找到了神奇的数字:它是 2 ^{-(有效数字精度位)}
这篇维基百科文章所详述。

I think I found the magical number: it is 2 ^{-(bits of significand precision)}
as detailed on this Wikipedia article.

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