且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果某个系统上的浮点数存储具有符号位,3位指数和4位有效数字:

更新时间:2023-11-08 13:45:34

这里有一些要解密的东西.

There're a few things to decipher here.

  • 指数:3位,2的补码,无偏差.这意味着指数可以表示范围在 -4 (对应于 100 )到 3 (对应于 011 )之间的值>).

  • Exponent: 3-bits, 2's complement, no bias. This means the exponent can represent values in the range -4 (corresponding to 100) to 3 (corresponding to 011).

没有隐含位的规范化:这意味着有效数始终以 1 开头.

Normalized without implied bit: This means significand always starts with a 1.

将它们放在一起时,可以写的最大数量为:

When you put these together, the maximum number you can write is:

 0 011 1111 = 2^3 * (2^-1 + 2^-2 + 2^-3 + 2^-4) = 7.5

由于浮点值在 0 附近是对称的,因此通过翻转上方的符号位,可以写入的最小值为 -7.5 .但是我想您的老师要求的是最低限度的正值(即非零).在这种情况下,我们选择指数越小越好,并仅保留有效位数的第一位以满足标准化要求.我们得到:

Since floating point values are symmetic around 0, the minumum value you can write is -7.5 by flipping the sign bit above. But I guess your teacher is going for minumum strictly positive (i.e., non-zero) value. In that case, we pick the exponent to be as small as possible, and just keep the first bit of the significand to satisfy the normalized requirement. We get:

 0 100 1000 = 2^-4 * 2^-1 = 2^-5 = 0.03125

希望如此!