计算指数位。

huangapple go评论45阅读模式
英文:

Calculate Exponent Bits

问题

我有关于比特的指数要问的问题
“32”的含义是从“0”到“31”。

然而,它们将被分为两个部分,正数部分和负数部分,总共有32个(“-16”.....“+15”)。

我的问题是,为什么是负数“-16”,我能否将其交换为(“-15”....“+16”),
以及如何找出负数“-16”和正数“15”的最大值?

一些可能性如
(“-11”.....“+20”)= 32,等等。

英文:

I have something to ask about the bit's exponent
计算指数位。The meaning of 32, is to count from 0 to 31.

However they will be divided into two parts positive and negative parts, which have a total of 32 (-16.....+15).

My question, why is it negative -16, can I swap it like (-15....+16),

and how can i find out the max of negative -16 and a maximum of positive 15?

Some possibilities like
(-11.....+20) = 32, and so on.

答案1

得分: 2

这是关于binary16编码的信息。

但是它们将被分成两个部分,正部分和负部分,共有32个(-16.....+15)

不是的。这5个"指数位"没有被分成两部分(-16.....+15)。图片中的"(-16.....+15)"标注是误导的

相反,将这5个"指数位"视为具有不同含义的偏置指数值[0...31],具体取决于值。

  1. [1...30](正常情况):_隐含的_有效位为1指数_为_偏置指数 - 指数偏差
指数 = 偏置指数 - 15
  1. [0...0](亚正常情况):_隐含的_有效位为0指数_为_1 - 指数偏差
指数 = 1 - 15
  1. [31...31]:特殊情况。该值为无穷大或非数字。

我的问题是,为什么是负数-16,我能不能像(-15....+16)这样交换吗,

不是-16。将其视为"-15....+16"更准确,除了边缘情况。

如何找出负数-16和正数15的最大值

最负的二进制指数是-14,最大的正数是15。

最大的binary16

1.1111 1111 1112 * 230 - 15 或 65504.0

最小的_正常_ binary16 是

1.0000 0000 0002 * 2-14 或 ≈ 6.10 × 10−5

最小的非零 binary16 是

0.0000 0000 0012 * 2-14 或 ≈ 5.96 × 10−8

英文:

This is about binary16 encoding.

> however they will be divided into two parts positive and negative parts, which have a total of 32 (-16.....+15)

No. The 5 exponent bits are not divided into two parts (-16.....+15). The "(-16.....+15)" note in the picture misleads.

Instead think of the 5 exponent bits as a biased exponent value [0...31] that have different meaning depending on value.

  1. [1...30] (normals): The implied significant bit is 1 and the exponent is biased exponent - exponent bias.
exponent = biased_exponent - 15
  1. [0...0] (sub-normals): The implied significant bit is 0 and the exponent is 1 - exponent bias.
exponent = 1 - 15 
  1. [31...31]: Special. The value is infinity or a not-a-number.

> my question, why is it negative -16, can I swap it like (-15....+16),

It is not -16. Considering it as "-15....+16" is more correct, aside for the edge cases.


> how can i find out the max of negative -16 and a maximum of positive 15

The most negative binary exponent is -14 and the maximum positive is 15.


The maximum binary16 is

1.1111 1111 111<sub>2</sub> * 2<sup>30 - 15</sup> or 65504.0

The minimum normal binary16 is

1.0000 0000 000<sub>2</sub> * 2<sup>-14</sup> or ≈ 6.10 × 10<sup>−5</sup>.

The minimum non-zero binary16 is

0.0000 0000 001<sub>2</sub> * 2<sup>-14</sup> or ≈ 5.96 × 10<sup>−8</sup>.

答案2

得分: 1

如果范围确实如您所发现的那样,那么可以如下理解:尾数值(1.m)_2,其中m是存储尾数部分的位串,取值介于1和2之间。因此,编码数字的范围从1*2^-16=2^-16到稍微小于2*2^15=2^16,在指数方面非常对称。

然而,偏置15将“原始”范围0..31转换为-15..16,只需进行简单的减法,无需超级秘密解码器。数字零由所有位为零表示,包括指数位(次正常数的指数位也都为零)。在另一端,所有指数位为一被用来编码无穷大和“fubar”结果(NaN)。

因此,可用于编码正常数字的指数范围为-14..15

根据上述逻辑,这给出了“大数比小数多4倍”的情况。另一方面,对于次正常数,这在一定程度上是平衡的(如果关心这种平衡的话,这都是相当随意的)。

英文:

If the ranges were indeed as you found them, then one could justify this as follows: The mantissa values (1.m)_2 where m is the bit string of the stored mantissa part, takes values between 1 and 2. So the range of encoded numbers is from 1*2^-16=2^-16 to shortly before 2*2^15=2^16, which is quite symmetric in the exponents.

However, the bias 15 shifts the "raw" range 0..31 to -15..16, simple subtraction, no super-secret decoder necessary. The number zero is represented by all bits zero, including the exponent bits (also the subnormal numbers have all exponent bits zero). On the opposite end, all exponent bits one is taken to encode infinity and "fubar" results (NaN).

> So the exponent range that is available to encode normal numbers is -14..15.

By the above logic, this gives "4 times more large numbers than small numbers". On the other hand, with the subnormals, this is balanced to some degree (if one cares for such a balance, it's all quite arbitrary).

huangapple
  • 本文由 发表于 2023年2月16日 14:07:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468429.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定