数字的二进制补码和其负数差? [英] Two's Complement of a number and its negative number difference?
问题描述
因此,我被告知二进制补码通常用于查找数字的补码,而我仅将其用于补正数(即positve->负转换),但是我在书中仅举了一个例子,问我以下:
So i was told that two's complement is usually to used to find complement of a number and I used it only to complement positive numbers (i.e positve --> negative conversion) however I just got an example in book which asks me the following :
以8位二进制2的补码表示23,-23和-9 表格
Express 23, -23, and -9 in 8-bit binary two’s Complement form
现在那是什么意思? 23表示二进制中的-23,-23表示23中的23?
now what does that mean? 23 means -23 in binary and -23 means 23 ?
sorta在那里困惑
sorta confused over there
推荐答案
2的补数用于表示负数,而负数又可以用于进行减法.
2's complement is used to represent negative numbers, which in turn, can be used to do subtraction.
23 = 00010111b
要获得-23(2的23的补数),请翻转所有位,然后添加1:
To get -23 (2's complement of 23), flip all the bits, and add 1:
11101000b + 1
=11101001b (-23)
-9是9的2的补码.9是
-9 is the 2's complement of 9. 9 is
00001001b
所以-9是
11110111b (Flipping and add +1)
另请参见此处
这篇关于数字的二进制补码和其负数差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!