在C中的双数据类型中的显着表示形式

发布于 2025-01-31 05:55:26 字数 504 浏览 2 评论 0 原文

我想确认,根据IEEE 754标准,C中的双数据类型中的显着表示形式始终是0到2之间的分数。

这是我读到的地方: https://stackoverflow.com/questions/30052710/why-double-can-store-bigger-numbers-numbers--than-than-than-than-nysigned-long-long#:text = the%20Reason%20Reason%20IS%20that %20unsigned,10308 )%20but%20NOT%20。

I want to confirm it that the significand representation in double data type in C is always a fraction between 0 and 2 with a 2^52 precision as per the IEEE 754 standard.

Here is where I read that:
https://stackoverflow.com/questions/30052710/why-double-can-store-bigger-numbers-than-unsigned-long-long#:~:text=The%20reason%20is%20that%20unsigned,10308)%20but%20not%20exactly.

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

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

发布评论

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

评论(1

沧桑㈠ 2025-02-07 05:55:26

我想确认,C中的双数据类型中的显着表示形式始终是0到2之间的分数,根据IEEE 754标准,具有2^52的精度。

不,不是。 C标准不需要符合C实现使用IEEE-754 Binary64格式(也称为“双精度”),用于 double 类型。

C标准将浮点数描述为在[0,1)中具有显着性,因为它使用了所有显着数字的形式,其中所有重要的数字均位于radix点的右侧。但是,这仅仅是缩放的问题,在数学上等同于更常用的形式,其中第一个数字在radix点的左侧。由于您询问的间隔(0,2)建议此形式,因此此答案使用该表格。

同样,“显着表示形式”与“显着”不同。 IEEE-754二进制64数的数学意义在[0,2)中(包括0的间隔,但不包括2),用于有限数。 (并且在[0,1)中的亚正常数中,[1,2)对于正常数。)但是,显着表示为52位的字符串与来自指数字段的一位结合在一起。 (如果指数字段为全零,则来自指数字段的位为0,如果指数字段既不是全部零也不是所有。 )

此外, +∞和−∞(加和减无穷大)是二进制64格式的代表数字,但在[0,2)中没有显着性。格式还提供了代表NAN(不是数字)的格式,该格式没有显着的值(尽管显着字段可能会提供有用的信息)。

如果C实现使用IEEE-754 binary64 for double (或使用底座二的任何格式),而A double 的“值”是有限的数字,那么它的意义在[0,2)中。

另请注意,“ 2^52 Precision”不是一个好术语,至少没有对那意味着什么的定义。什么是3精度或8精度?一个数字本身几乎没有意义。 2 52 是显着范围中最大和最不重要位的位置值之间的比率,尽管亚正态分数无法维持该跨度。

I want to confirm it that the significand representation in double data type in C is always a fraction between 0 and 2 with a 2^52 precision as per the IEEE 754 standard.

No, it is not. The C standard does not require that conforming C implementations use the IEEE-754 binary64 format (also called “double precision”) for the double type.

The C standard describes floating-point numbers as having significands in [0, 1), because it uses a form in which all the significant digits are to the right of the radix point. However, this is simply a matter of scaling and is mathematically equivalent to the more commonly used form in which the first digit is to the left of the radix point. Since this form is suggested by the interval you ask about, [0, 2), this answer uses that form.

Also, “the significand representation” is different from “the significand.” The mathematical significand of an IEEE-754 binary64 number is in [0, 2) (the interval including 0 but excluding 2) for finite numbers. (And it is in [0, 1) for subnormal numbers and [1, 2) for normal numbers.) However, the significand representation is a string of 52 bits combined with one bit from the exponent field. (That bit from the exponent field is 0 if the exponent field is all zeros and 1 if the exponent field is neither all zeros nor all ones. If it is all ones, the significand is not applicable because it is representing an infinity or NaN.)

Further, +∞ and −∞ (plus and minus infinity) are representable numbers in the binary64 format but do not have significands in [0, 2). And the format also provides for representing NaN (Not a Number), which does not have a significand value (although the significand field may provide useful information).

If a C implementation uses IEEE-754 binary64 for double (or any format using base two), and the “value” of a double is a finite number, then its significand is in [0, 2).

Also note that “2^52 precision” is not a good term, at least not without some definition of what that means. What is 3 precision or 8 precision? A number by itself has little meaning. 252 is the ratio between the position values of the most and least significant bits in the significand, although subnormal numbers are unable to maintain that span.

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