问题描述
一个正数的二进制补码表示法和它的二进制表示法一样吗?
Is two's complement notation of a positive number is same as its binary representation?
推荐答案
一个很好的例子来自 wiki,通过注意实现与二进制补码的关系即 256 = 255 + 1,并且 (255 - x) 是 x 的补码
The good example is from wiki that the relationship to two's complement is realized by noting that 256 = 255 + 1, and (255 − x) is the ones' complement of x
0000 0111=7 二进制补码是 1111 1001= -7
0000 0111=7 two's complement is 1111 1001= -7
它的工作方式是 msb(最高有效位)接收一个负值,因此在上述情况下
the way it works is the msb(most significant bit) receives a negative value so in the case above
-7 = 1001= -8 + 0+ 0+ 1
Edit- 用二进制补码表示的正数与用无符号表示的数字相同(尽管最高有效位必须为零).负数可以用二进制补码表示法写入,方法是将其绝对值的所有位取反,然后将结果加 1.双补符号
Edit- A positive number written in two's-complement notation is the same as the number written in unsigned notation (although the most significant bit must be zero). A negative number can be written in two's complement notation by inverting all of the bits of its absolute value, then adding one to the result. Two's-complement notation
k位二进制补码表示法可以表示的最大数是2^(k-1)−1
The maximum number that can be represented with a k-bit two's-complement notation is 2^(k-1)−1
这篇关于正数的二进制补码表示法是同一个数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!