如果某个系统上的浮点数存储具有符号位,3位指数和4位有效数字: [英] If the floating-point number storage on a certain system has a sign bit, a 3-bit exponent, and a 4-bit significand:

查看:102
本文介绍了如果某个系统上的浮点数存储具有符号位,3位指数和4位有效数字:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(假设没有隐含位,没有偏差,指数使用2的补码表示法,并且允许全零和全1的指数.)我正在尝试查找如果系统标准化则可以表示的最大和最小数字.我认为最大的数字是:

(Assume no bits are implied, there is no biasing, exponents use two’s complement notation, and exponents of all zeros and all ones are allowed.) I am trying to find the largest and smallest number that can be represented if the system is normalized. I thought that the largest number would be:

.1111 x 2^4 = 0 100 1111 = 15

,最小的:

1.0 x 2^-4 = 0 000 0001 = 0.0625

但是我看到的答案是:

Largest: .1111 x 2^3 = 111.1 = 7.5

Smallest: 0.1 x 2^-4 = .00001 = 0.03125

我不明白以4位有效位数怎么可能回答这两个问题.

I do not understand how either answer would even be possible in a 4-bit significand.

推荐答案

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

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

希望如此!

这篇关于如果某个系统上的浮点数存储具有符号位,3位指数和4位有效数字:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆