双长补重二进制数presentation? [英] Doubleword-length 2’s complement representation of Binary number?
问题描述
做我的第一次汇编分配和这提出了一个问题...
Doing my first assignment in Assembler and this is the question posed...
1.Find以下每个十进制数的双字长度2的补重新presentation。 (必须显示让你的结果的步骤,否则,你得到的零点。)
1.Find the doubleword-length 2’s complement representation of each of the following decimal numbers. (Steps of getting your results must be displayed, otherwise you get zero point.)
-100
乙-55555
我有一个非常外籍教授,我完全无法理解,所以我需要一些援助。这样一个双字将是32位这将使...
I have a very foreign professor that I completely can't understand so I'm in need of some assistance. So a doubleword would be 32 bits which would make...
A) 0000 | 0000 | 0000 | 0000 | 0000 | 0001 | 0000 | 0000
( 1
在开始负| 0001
1 | 0000
0 | 0000
0 |。前导0的填料
A) 0000|0000|0000|0000|0000|0001|0000|0000
(1
at beginning for negative|0001
for 1|0000
for 0|0000
for 0|leading 0's for filler.
二)1000 | 0000 | 0000 | 0101 | 0101 | 0101 | 0101 | 0101( 1
在开始负| 00000000
为填料0 |,其余 0101
5的
b) 1000|0000|0000|0101|0101|0101|0101|0101 (1
at beginning for negative| 00000000
for filler 0's|the rest 0101
for 5's.
由于不知何故正确的,2的补会。
Given that's somehow correct, the 2's complement would be..
我不知道。我学会例子和我的教授没有做任何。如果任何人都可以通过一个为我跑,我会非常感激。我知道有计算器在那里他们三三两两恭维,将转换小数,但我想知道如何做到这一点。再次感谢。
I don't know. I learn by examples and my professor didn't do any. If anyone could run through one for me I'd be very grateful. I know there are calculators out there that will convert decimals to their twos compliment but I want to know HOW to do it. Thanks again.
推荐答案
之路偏离了轨道。还记得他们是小数,你不能只是突然pretend他们是十六进制(并使用半字节),而只是把1开头讲述的是作为远离补除去,你可以。
Way off track. Remember they were decimal numbers, you can't just suddenly pretend they're hexadecimal (and use nibbles), and "just putting a 1 at the beginning" is about as far removed from two's complement as you can be.
因此,让我们开始在一开始,转换100和55555为二进制。减去两个最高权力,将进入它,相应的位设置为1。因此,对于100:
So let's begin at the start, convert 100 and 55555 to binary. Subtract the highest power of two that will go into it, set the corresponding bit to 1. So for 100:
100 - 64 = 36, set bit 1000000
36 - 32 = 4, set bit 100000
4 - 4 = 0, set bit 100
------- +
1100100
或 0x64
十六进制。 55555只是更多的相同。
Or 0x64
in hexadecimal. 55555 is just more of the same.
您可能已经了解到(或应该已经学会)的身份 -x =〜X + 1
,使用它的简单否定100和55555以二进制再presentation,宽,你想要得到的结果是(32位),所以
You've probably learned (or should have learned) the identity -x = ~x + 1
, using that it's simple to negate 100 and 55555. Take the binary representation, as wide as you want the result to be (32 bits), so
0000 0000 0000 0000 0000 0000 0110 0100
反转所有位:
1111 1111 1111 1111 1111 1111 1001 1011
添加1:
1111 1111 1111 1111 1111 1111 1001 1100
或 0xFFFFFF9C
十六进制的。
这篇关于双长补重二进制数presentation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!