处理小数字和准确性

发布于 2024-10-14 10:21:15 字数 178 浏览 10 评论 0原文

我有一个程序,可以处理很多非常小的数字(接近双极限的下限)。

在我的应用程序执行过程中,其中一些数字逐渐变小,这意味着它们的“估计”不太准确。

我目前的解决方案是在进行任何计算之前放大它们,然后再次缩小它们?

...但这让我思考,这样做是否真的获得了更多的“准确性”?

想法?

I have a program where I deal with a lot of very small numbers (towards the lower end of the Double limits).

During the execution of my application, some of these numbers progressively get smaller meaning their "estimation" is less accurate.

My solution at the moment is scaling them up before I do any calculations and then scaling them back down again?

...but it's got me thinking, am I actually gaining any more "accuracy" by doing this?

Thoughts?

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

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

发布评论

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

评论(2

み零 2024-10-21 10:21:15

您的数字是否真的在 10^-308(最小标准化双精度)和 10^-324(最小可表示双精度,非标准化,即丢失精度)之间?如果是这样,那么通过放大它们,您确实可以通过解决双精度类型的指数范围的限制来获得准确性。

但我想知道:什么样的应用程序可以处理这么小的数字?据我所知,没有任何体能训练需要这样的东西。

Are your numbers really in the region between 10^-308 (smallest normalized double) and 10^-324 (smallest representable double, denormalized i.e. losing precision)? If so, then by scaling them up you do indeed gain accuracy by working around the limits of the exponent range of the double type.

I have to wonder though: what kind of application deals with numbers that extremely small? I know of no physical discipline that needs anything like that.

只等公子 2024-10-21 10:21:15

双精度数具有固定数量的有效数字,以及另一个固定数量的字节来表示“幂”部分。

因此,事实上您可能会遇到两个问题:

  1. 关于功率部分:这就是接近小双打极限的问题。
    将它们放大(按 2 的幂)有助于避免您的数字变得不再具有代表性。

  2. 当您写到“估计”的准确性时,我假设您指的是有效位数:这与小数限制无关。一个非常小的数字,但就双精度数下限而言并不算太小,它与任何“更正常”的数字具有相同的有效位数。
    一般来说,对数字的数值精度的关注应该集中在数字的计算方式上,而不是结果的绝对大小上。

A double has a fixed number of significant digits, and another fixed number of bytes to represent the "power"-part.

In fact you may, therefore, have two issues:

  1. Regarding the power-part: that is what approaching the limit of small doubles is about.
    Scaling them up (by powers of 2) helps avoid that your number becomes no longer representable.

  2. when you write about the the accuracy of "estimation", I assume you refer to the number of significant digits: that is not related to the small-number-limit. A number that is very small, but not too small in the sense of the lower limit for doubles, has the same number of significant digits as any "more normal" number.
    Concerns about numerical precision of a number should, generally speaking, focus on how the number is computed, rather than on the absolute size of the result.

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