简体   繁体   English

标准化浮点表示

[英]Normalised Floating point representation

I'm trying to help someone out with some homework and I'm getting erroneous answers. 我正在尝试帮助某人做一些功课,并且得到了错误的答案。

The question is this: 问题是这样的:

Represent 〖-0.109375〗_10 in normalized floating point representation having a 5-bit fractional two's complement mantissa and a 3-bit integer two's complement exponent. 用归一化的浮点表示来表示〖-0.109375〗_10,该浮点表示具有5位分数的二进制补码尾数和3位整数的二进制补码指数。

I have written the following notes: 我写了以下笔记:

Let's work out the answer to the question: 〖-0.109375〗_10 Step 1: Convert to binary. 让我们找出问题的答案:〖-0.109375〗_10步骤1:转换为二进制。

0 0. 0 0 0 1 1 1 0 0 0 0. 0 0 0 1 1 1 0 0

〖-(00.00011100)〗_2 〖 - (00.00011100)〗_ 2

Step 2: Multiply by 1 (2^0) 〖-(00.00011100)〗_2 x 2^0 步骤2:乘以1(2 ^ 0)〖-((00.00011100)} _ 2 x 2 ^ 0

Step 3: Shift to make mantissa whole number We need to make 6 shifts to the left Why? 第3步:移位以使尾数为整数我们需要向左移位6次为什么? Because we have 0.000111 Shift 1 = 00.00111 Shift 2 = 000.0111 Shift 3 = 0000.111 Shift 4 = 00001.11 Shift 5 = 000011.1 Shift 6 = 0000111 因为我们有0.000111档1 = 00.00111档2 = 000.0111档3 = 0000.111档4 = 00001.11档5 = 000011.1档6 = 0000111

Therefore we get, -(〖111〗_2) x 2^(-6) 因此我们得到-(〖111〗_2)x 2 ^(-6)

Step 4: Convert mantissa. 步骤4:转换尾数。 In this question we were requested to convert to two's complement (5-bit fractional) Therefore we need to convert – 111 to two's complement and make this 5 bit 在此问题中,我们被要求转换为二进制补码(5位小数),因此我们需要将– 111转换为二进制补码,并将其变为5位

Step A: Convert to one's complement (5 bit) -00111 = 11000 Step B: Convert to two's complement (5-bit) 11000 + 00001 = 〖11001〗_2 步骤A:转换为二进制补码(5位)-00111 = 11000步骤B:转换为二进制补码(5位)11000 + 00001 =〖11001〗_2

Step 5: Convert exponent top 2-bit two's complement 2^(-6) 步骤5:转换指数高2位二进制补码2 ^(-6)

Therefore we need to convert -6 to binary (two's complement) Step A: Convert to binary 1 1 0 因此,我们需要将-6转换为二进制(二进制补码)步骤A:转换为二进制1 1 0

Step B: Convert to one's complement (3-bit) 110 = 001 步骤B:转换为补码(3位)110 = 001

Step C: Convert to two's complement 010 步骤C:转换为二进制补码010

The answer is then, 〖11001 010〗_2 答案是〖11001 010〗_2

As you can see, 2^-6 seems wrong for a 3-bit two's complement. 如您所见,对于3位二进制补码,2 ^ -6似乎是错误的。

Can anyone point out what I might be doing wrong? 谁能指出我可能做错了什么?

Usually the significand (not mantissa 1 ) is shifted so the most significant one bit is in a certain position, not so the significand is an integer. 通常,有效数(不是尾数1 )被移位,因此最高有效位在某个位置,而不是有效数是整数。 The IEEE 754 format normalizes the significand to 1. ddd…d , where each d is a digit in the base being used. IEEE 754格式将有效位数标准化为1. ddd…d ,其中每个d是所使用的基数中的一个数字。

Shifting your value to move the first one bit to that position yields an exponent of –4. 移位您的值以将第一个位移动到该位置将产生–4的指数。 You would have –1.110 2 •2 –4 . 您将获得–1.110 2 •2 –4 To represent the significand in two's complement, we add another bit on the left, producing –01.110 2 •2 –4 , and then apply the negation to yield 10.010 for the significand and 100 for the exponent. 为了表示有效位数为2的补码,我们在左边添加另一位,产生–01.110 2 •2 –4 ,然后应用负数生成有效位数10.010和指数100。

However, there can be some variation on details. 但是,细节可能有所不同。 Is the significand normalized to 1. ddd…d or .1 ddd…d ? 有效位数是否已标准化为1. ddd…d或.1 ddd…d Is the significand five bits before adding a sign bit or after? 在添加符号位之前或之后,有效位数是5位吗?

Do you have examples of values with known representations in this format? 您是否有采用这种格式的具有已知表示形式的值的示例? Or more details about the format? 还是有关格式的更多详细信息?


1 “Significand” is the preferred term. 1 “有效”是首选术语。 A significand is linear; 有效数字是线性的; a mantissa is logarithmic. 尾数是对数的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM