大双精度数/浮点数/数字

发布于 2024-11-03 05:05:16 字数 73 浏览 3 评论 0原文

假设我有一个巨大的浮点数,小数点后一万亿位。显然长双倍无法承受这一点。我们还假设我有一台内存足够容纳它的计算机。你怎么做这样的事情?

Say I have a huge floating number, say a trillion decimal places out. Obviously a long double can't hold this. Let's also assume I have a computer with more than enough memory to hold it. How do you do something like this?

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

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

发布评论

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

评论(4

旧时光的容颜 2024-11-10 05:05:17

说“任意精度算术”(或类似的东西)很容易,但我认为值得补充的是,很难想象如何将数字放置在接近这个大小的任何地方来使用。

举个例子:目前对宇宙大小的估计约为 150-2000 亿光年。在光谱的另一端,单个电子的直径估计略小于 1 个原子。 1 光年大约为 9.46x1015 米(为简单起见,我们将其视为 1016 米)。

那么,让我们以 1 原子米为单位,并计算出该单位中宇宙直径的数字大小。 1018 单位/米 * 1016 米/光年 * 1011 光年/宇宙直径 = 大约 45 位数字来表示宇宙的直径,单位大致为电子直径。

即使我们进行下一步,并用超弦的理论大小来表达它,并添加一些额外的数字,以防当前的估计偏离几个数量级,我们仍然会得到一个号码大约65位左右。

这意味着,例如,如果我们知道宇宙的直径相当于单个超弦的大小,并且我们想要计算类似超弦直径的宇宙体积之类的东西,那么我们最大的中间结果将类似于 600- 700位左右。

考虑另一个要点:如果你要对一台运行速度为 10 GHz 的 64 位计算机进行编程,除了计数之外什么都不做——每个时钟周期递增寄存器一次——那么它需要大约 1400 年的时间才能完成循环。 64 位数字,因此它再次返回到 0。

最重要的是,要找出任何接近数百万、数十亿/百万或数万亿/数十亿位数的计算的借口(更不用说真正的原因)是极其困难的。宇宙没有那么大,不包含那么多原子等等。

It's easy to say "arbitrary precision arithmetic" (or something similar), but I think it's worth adding that it's difficult to conceive of ways to put numbers anywhere close to this size to use.

Just for example: the current estimates of the size of the universe are somewhere in the vicinity of 150-200 billion light years. At the opposite end of the spectrum, the diameter of a single electron is estimated at a little less than 1 atometer. 1 light year is roughly 9.46x1015 meters (for simplicity, we'll treat it as 1016 meters).

So, let's take 1 atometer as our unit, and figure out the size of number for the diameter of the universe in that unit. 1018 units/meter * 1016 meters/light year * 1011 light years/universe diameter = about a 45 digit number to express the diameter of the universe in units of roughly the diameter of an electron.

Even if we went the next step, and expressed it in terms of the theorized size of a superstring, and added a few extra digits just in case the current estimates are off by a couple orders of magnitude, we'd still end up with a number around 65 digits or so.

This means, for example, that if we knew the diameter of the universe to the size of a single superstring, and we wanted to compute something like volume of the universe in terms of superstring diameters, our largest intermediate result would be something like 600-700 digits or so.

Consider another salient point: if you were to program a 64-bit computer running at, say, 10 GHz to do nothing but count -- increment a register once per clock cycle -- it would take roughly 1400 years for it to just cycle through the 64-bit numbers so it wrapped around to 0 again.

The bottom line is that it's incredibly difficult to come up with excuses (much less real reasons) to carry out calculations to anywhere close to millions, billions/milliards or trillions/billions of digits. The universe isn't that big, doesn't contain that many atoms, etc.

好菇凉咱不稀罕他 2024-11-10 05:05:17

听起来像是发明对数的目的。

如果不知道您打算如何处理该数字,就不可能准确地说出如何表示它。

Sounds like what logarithms were invented for.

Without knowing what you intend to do with the number, it's impossible to accurately say how to represent it.

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