十进制数学是否使用 FPU

发布于 2025-01-02 18:54:00 字数 95 浏览 2 评论 0原文

十进制数学是否使用 FPU?

我认为答案是肯定的,但我不确定,因为小数不是浮点数,而是固定精度的数字。

我主要寻找.NET,但一般答案也很有用。

Does decimal math use the FPU?

I would think that the answer is yes, but I'm not sure, since a decimal is not a floating point, but a fixed precision number.

I'm looking mostly for .NET, but a general answer would be useful too.

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

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

发布评论

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

评论(2

薄凉少年不暖心 2025-01-09 18:54:00

对于 .NET,更具体地说是 C#,不,System.Decimal 不使用 FPU,因为该类型是在软件中模拟的。

另外,System.Decimal 浮点数,而不是数据库中常见的固定精度数字。该类型实际上是一个十进制浮点,它使用 10 作为其基数,而不是二进制浮点(即 System.SingleSystem.Double),它使用 2 作为基数。如果您尝试存储无法精确表示的分数(例如 1/3),它仍然存在相同的精度问题。

With regards to .NET and more specifically C#, no, System.Decimal does not use the FPU because the type is emulated in software.

Also, System.Decimal is a floating point number, not a fixed precision number like commonly found in a database. The type is actually a decimal floating point that uses 10 for its base as opposed to a binary floating point (i.e. System.Single or System.Double) which uses 2 as its base. It still has the same precision problems if you attempt to store a fraction that cannot be exactly represented, for example, 1/3.

祁梦 2025-01-09 18:54:00

是的,现代语言通常支持浮点数学整数数学,仅此而已;不直接支持定点、BCD 等。浮点数学将使用浮点处理器指令完成;现代架构不包含单独的 FPU。

Yes, modern languages in general support floating point math and integer math, and that's it; there's no direct support for fixed point, BCD, etc. Floating-point math is going to be done using floating-point processor instructions; modern architectures don't include a separate FPU.

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