2 つの 2 の補数の 2 進数を加算して出力を吐き出すプログラムがあります。それらは、2 の補数である最初の 2 進数としてファイルから読み取られます。2 番目の 2 進数が偏った表記になっています。2 の補数にバイアスされた形式を変更するには、左端のビットを反転します。次に、2 つの 2 進数を加算し、ファイルに出力します。私が問題を抱えているのは、出力を理解することです。次の出力は、最初の 2 進数が 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 番目の例を考えると、3 + 7 = 6 となります。これは正しいのでしょうか? 正しくないようですが、他の例は正しいです。-16 + 8 = -8 のように。
だから私の質問は...このファイルの出力は正しいですか?