我有一个程序,添加2,2的补码二进制数,并吐出输出。它们是从一个文件中读取的,作为第一个二进制数在两个的补码中。第二个二进制数用有偏符号表示。为了改变形式偏向于二的补语,我们翻转最左边的位。然后,我们将这两个二进制数字添加到文件中,并给出输出。我遇到的困难是理解输出。这是输出,其中第一个二进制数是在两个的补码和第二个有偏表示法。
01000000 <- 2's complement 64
+ 11000000 <- biased notation 64
-----------------------------------------------
10000000 <- 2's complement Overflow
01111111 <- 2's complement 127
+ 00000000 <- biased notation -128
-----------------------------------------------
11111111 <- 2's complement -1
00000011 <- 2's complement 3
+ 10000111 <- biased notation 7
-----------------------------------------------
00000110 <- 2's complement 6
00001111 <- 2's complement 15
+ 10000111 <- biased notation 7
-----------------------------------------------
00010010 <- 2's complement 18
10000000 <- 2's complement -128
+ 11111111 <- biased notation 127
-----------------------------------------------
11111111 <- 2's complement -1
11110000 <- 2's complement -16
+ 10001000 <- biased notation 8
-----------------------------------------------
11111000 <- 2's complement -8
10000001 <- 2's complement -127
+ 00000001 <- biased notation -127
-----------------------------------------------
00000010 <- 2's complement Underflow
01111111 <- 2's complement 127
+ 00000000 <- biased notation -128
-----------------------------------------------
11111111 <- 2's complement -1
01110101 <- 2's complement 117
+ 11010001 <- biased notation 81
-----------------------------------------------
01000110 <- 2's complement 70
00000000 <- 2's complement 0
+ 10000000 <- biased notation 0
-----------------------------------------------
00000000 <- 2's complement 0
00001111 <- 2's complement 15
+ 11110000 <- biased notation 112
-----------------------------------------------
01111111 <- 2's complement 127
00001111 <- 2's complement 15
+ 10000001 <- biased notation 1
-----------------------------------------------
00010000 <- 2's complement 16
00000111 <- 2's complement 7
+ 11110000 <- biased notation 112
-----------------------------------------------
01110111 <- 2's complement 119
11111111 <- 2's complement -1
+ 01111111 <- biased notation -1
-----------------------------------------------
10101010 <- 2's complement -86
00000000 <- 2's complement 0
+ 10000000 <- biased notation 0
-----------------------------------------------
00000000 <- 2's complement 0
11111111 <- 2's complement -1
+ 11111111 <- biased notation 127
-----------------------------------------------
00101010 <- 2's complement 42第三个例子是3+7= 6,这是正确的吗?这似乎不对,但其他例子是正确的。类似-16 +8= -8。
所以我的问题是..。这个文件的输出正确吗?
发布于 2015-02-11 22:58:00
看起来,每当你有3次连续携带时,它就会下降1。与下一次相同,15 + 7。它没有正确地进行携带。
11 <- carry
0011 = 3
+0111 = 7
1010 = 10https://stackoverflow.com/questions/28461835
复制相似问题