Fully solved problem book
Eight-bit subtraction
Set 6 of 14 · 32 worked questions. Predict your result before expanding the solution.
These worked traces are meant to build fluency through controlled variation. If several answers feel identical, try the next difficult value and look for the point where a carry, sign, branch, or selected memory address changes the outcome.
Bitwise arithmetic · Problem 0161
Calculate 94 − 81 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011110 and B=01010001.
- The unsigned values are A=94 and B=81.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010001 → 10101110.
- Add one to the inverted byte: 10101110 + 1 → 10101111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011110 + 10101111.
- Keep only the lowest eight bits: 00001101.
- Normal integers give 94−81=13.
- After modulo 256, the result is 13.
- The signed interpretation of the output byte is 13.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00001101 (13 unsigned)
Bitwise arithmetic · Problem 0162
Calculate 94 − 105 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011110 and B=01101001.
- The unsigned values are A=94 and B=105.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01101001 → 10010110.
- Add one to the inverted byte: 10010110 + 1 → 10010111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011110 + 10010111.
- Keep only the lowest eight bits: 11110101.
- Normal integers give 94−105=-11.
- After modulo 256, the result is 245.
- The signed interpretation of the output byte is -11.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11110101 (245 unsigned)
Bitwise arithmetic · Problem 0163
Calculate 94 − 224 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011110 and B=11100000.
- The unsigned values are A=94 and B=224.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100000 → 00011111.
- Add one to the inverted byte: 00011111 + 1 → 00100000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011110 + 00100000.
- Keep only the lowest eight bits: 01111110.
- Normal integers give 94−224=-130.
- After modulo 256, the result is 126.
- The signed interpretation of the output byte is 126.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01111110 (126 unsigned)
Bitwise arithmetic · Problem 0164
Calculate 95 − 191 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011111 and B=10111111.
- The unsigned values are A=95 and B=191.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10111111 → 01000000.
- Add one to the inverted byte: 01000000 + 1 → 01000001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011111 + 01000001.
- Keep only the lowest eight bits: 10100000.
- Normal integers give 95−191=-96.
- After modulo 256, the result is 160.
- The signed interpretation of the output byte is -96.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10100000 (160 unsigned)
Bitwise arithmetic · Problem 0165
Calculate 95 − 231 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011111 and B=11100111.
- The unsigned values are A=95 and B=231.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100111 → 00011000.
- Add one to the inverted byte: 00011000 + 1 → 00011001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011111 + 00011001.
- Keep only the lowest eight bits: 01111000.
- Normal integers give 95−231=-136.
- After modulo 256, the result is 120.
- The signed interpretation of the output byte is 120.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01111000 (120 unsigned)
Bitwise arithmetic · Problem 0166
Calculate 97 − 147 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100001 and B=10010011.
- The unsigned values are A=97 and B=147.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10010011 → 01101100.
- Add one to the inverted byte: 01101100 + 1 → 01101101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100001 + 01101101.
- Keep only the lowest eight bits: 11001110.
- Normal integers give 97−147=-50.
- After modulo 256, the result is 206.
- The signed interpretation of the output byte is -50.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11001110 (206 unsigned)
Bitwise arithmetic · Problem 0167
Calculate 97 − 174 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100001 and B=10101110.
- The unsigned values are A=97 and B=174.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10101110 → 01010001.
- Add one to the inverted byte: 01010001 + 1 → 01010010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100001 + 01010010.
- Keep only the lowest eight bits: 10110011.
- Normal integers give 97−174=-77.
- After modulo 256, the result is 179.
- The signed interpretation of the output byte is -77.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110011 (179 unsigned)
Bitwise arithmetic · Problem 0168
Calculate 98 − 127 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100010 and B=01111111.
- The unsigned values are A=98 and B=127.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01111111 → 10000000.
- Add one to the inverted byte: 10000000 + 1 → 10000001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100010 + 10000001.
- Keep only the lowest eight bits: 11100011.
- Normal integers give 98−127=-29.
- After modulo 256, the result is 227.
- The signed interpretation of the output byte is -29.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11100011 (227 unsigned)
Bitwise arithmetic · Problem 0169
Calculate 98 − 165 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100010 and B=10100101.
- The unsigned values are A=98 and B=165.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10100101 → 01011010.
- Add one to the inverted byte: 01011010 + 1 → 01011011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100010 + 01011011.
- Keep only the lowest eight bits: 10111101.
- Normal integers give 98−165=-67.
- After modulo 256, the result is 189.
- The signed interpretation of the output byte is -67.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10111101 (189 unsigned)
Bitwise arithmetic · Problem 0170
Calculate 100 − 43 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100100 and B=00101011.
- The unsigned values are A=100 and B=43.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00101011 → 11010100.
- Add one to the inverted byte: 11010100 + 1 → 11010101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100100 + 11010101.
- Keep only the lowest eight bits: 00111001.
- Normal integers give 100−43=57.
- After modulo 256, the result is 57.
- The signed interpretation of the output byte is 57.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00111001 (57 unsigned)
Bitwise arithmetic · Problem 0171
Calculate 100 − 142 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100100 and B=10001110.
- The unsigned values are A=100 and B=142.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001110 → 01110001.
- Add one to the inverted byte: 01110001 + 1 → 01110010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100100 + 01110010.
- Keep only the lowest eight bits: 11010110.
- Normal integers give 100−142=-42.
- After modulo 256, the result is 214.
- The signed interpretation of the output byte is -42.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11010110 (214 unsigned)
Bitwise arithmetic · Problem 0172
Calculate 101 − 6 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100101 and B=00000110.
- The unsigned values are A=101 and B=6.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000110 → 11111001.
- Add one to the inverted byte: 11111001 + 1 → 11111010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100101 + 11111010.
- Keep only the lowest eight bits: 01011111.
- Normal integers give 101−6=95.
- After modulo 256, the result is 95.
- The signed interpretation of the output byte is 95.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01011111 (95 unsigned)
Bitwise arithmetic · Problem 0173
Calculate 101 − 79 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100101 and B=01001111.
- The unsigned values are A=101 and B=79.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01001111 → 10110000.
- Add one to the inverted byte: 10110000 + 1 → 10110001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100101 + 10110001.
- Keep only the lowest eight bits: 00010110.
- Normal integers give 101−79=22.
- After modulo 256, the result is 22.
- The signed interpretation of the output byte is 22.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00010110 (22 unsigned)
Bitwise arithmetic · Problem 0174
Calculate 102 − 16 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100110 and B=00010000.
- The unsigned values are A=102 and B=16.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00010000 → 11101111.
- Add one to the inverted byte: 11101111 + 1 → 11110000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100110 + 11110000.
- Keep only the lowest eight bits: 01010110.
- Normal integers give 102−16=86.
- After modulo 256, the result is 86.
- The signed interpretation of the output byte is 86.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01010110 (86 unsigned)
Bitwise arithmetic · Problem 0175
Calculate 103 − 38 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01100111 and B=00100110.
- The unsigned values are A=103 and B=38.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100110 → 11011001.
- Add one to the inverted byte: 11011001 + 1 → 11011010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01100111 + 11011010.
- Keep only the lowest eight bits: 01000001.
- Normal integers give 103−38=65.
- After modulo 256, the result is 65.
- The signed interpretation of the output byte is 65.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01000001 (65 unsigned)
Bitwise arithmetic · Problem 0176
Calculate 104 − 109 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101000 and B=01101101.
- The unsigned values are A=104 and B=109.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01101101 → 10010010.
- Add one to the inverted byte: 10010010 + 1 → 10010011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101000 + 10010011.
- Keep only the lowest eight bits: 11111011.
- Normal integers give 104−109=-5.
- After modulo 256, the result is 251.
- The signed interpretation of the output byte is -5.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11111011 (251 unsigned)
Bitwise arithmetic · Problem 0177
Calculate 105 − 209 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101001 and B=11010001.
- The unsigned values are A=105 and B=209.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11010001 → 00101110.
- Add one to the inverted byte: 00101110 + 1 → 00101111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101001 + 00101111.
- Keep only the lowest eight bits: 10011000.
- Normal integers give 105−209=-104.
- After modulo 256, the result is 152.
- The signed interpretation of the output byte is -104.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10011000 (152 unsigned)
Bitwise arithmetic · Problem 0178
Calculate 106 − 83 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101010 and B=01010011.
- The unsigned values are A=106 and B=83.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010011 → 10101100.
- Add one to the inverted byte: 10101100 + 1 → 10101101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101010 + 10101101.
- Keep only the lowest eight bits: 00010111.
- Normal integers give 106−83=23.
- After modulo 256, the result is 23.
- The signed interpretation of the output byte is 23.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00010111 (23 unsigned)
Bitwise arithmetic · Problem 0179
Calculate 108 − 97 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101100 and B=01100001.
- The unsigned values are A=108 and B=97.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01100001 → 10011110.
- Add one to the inverted byte: 10011110 + 1 → 10011111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101100 + 10011111.
- Keep only the lowest eight bits: 00001011.
- Normal integers give 108−97=11.
- After modulo 256, the result is 11.
- The signed interpretation of the output byte is 11.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00001011 (11 unsigned)
Bitwise arithmetic · Problem 0180
Calculate 108 − 157 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101100 and B=10011101.
- The unsigned values are A=108 and B=157.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011101 → 01100010.
- Add one to the inverted byte: 01100010 + 1 → 01100011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101100 + 01100011.
- Keep only the lowest eight bits: 11001111.
- Normal integers give 108−157=-49.
- After modulo 256, the result is 207.
- The signed interpretation of the output byte is -49.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11001111 (207 unsigned)
Bitwise arithmetic · Problem 0181
Calculate 109 − 232 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101101 and B=11101000.
- The unsigned values are A=109 and B=232.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101000 → 00010111.
- Add one to the inverted byte: 00010111 + 1 → 00011000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101101 + 00011000.
- Keep only the lowest eight bits: 10000101.
- Normal integers give 109−232=-123.
- After modulo 256, the result is 133.
- The signed interpretation of the output byte is -123.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10000101 (133 unsigned)
Bitwise arithmetic · Problem 0182
Calculate 109 − 253 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101101 and B=11111101.
- The unsigned values are A=109 and B=253.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111101 → 00000010.
- Add one to the inverted byte: 00000010 + 1 → 00000011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101101 + 00000011.
- Keep only the lowest eight bits: 01110000.
- Normal integers give 109−253=-144.
- After modulo 256, the result is 112.
- The signed interpretation of the output byte is 112.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01110000 (112 unsigned)
Bitwise arithmetic · Problem 0183
Calculate 110 − 183 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101110 and B=10110111.
- The unsigned values are A=110 and B=183.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110111 → 01001000.
- Add one to the inverted byte: 01001000 + 1 → 01001001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101110 + 01001001.
- Keep only the lowest eight bits: 10110111.
- Normal integers give 110−183=-73.
- After modulo 256, the result is 183.
- The signed interpretation of the output byte is -73.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110111 (183 unsigned)
Bitwise arithmetic · Problem 0184
Calculate 111 − 66 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101111 and B=01000010.
- The unsigned values are A=111 and B=66.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01000010 → 10111101.
- Add one to the inverted byte: 10111101 + 1 → 10111110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101111 + 10111110.
- Keep only the lowest eight bits: 00101101.
- Normal integers give 111−66=45.
- After modulo 256, the result is 45.
- The signed interpretation of the output byte is 45.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00101101 (45 unsigned)
Bitwise arithmetic · Problem 0185
Calculate 111 − 99 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101111 and B=01100011.
- The unsigned values are A=111 and B=99.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01100011 → 10011100.
- Add one to the inverted byte: 10011100 + 1 → 10011101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101111 + 10011101.
- Keep only the lowest eight bits: 00001100.
- Normal integers give 111−99=12.
- After modulo 256, the result is 12.
- The signed interpretation of the output byte is 12.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00001100 (12 unsigned)
Bitwise arithmetic · Problem 0186
Calculate 111 − 128 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101111 and B=10000000.
- The unsigned values are A=111 and B=128.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10000000 → 01111111.
- Add one to the inverted byte: 01111111 + 1 → 10000000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101111 + 10000000.
- Keep only the lowest eight bits: 11101111.
- Normal integers give 111−128=-17.
- After modulo 256, the result is 239.
- The signed interpretation of the output byte is -17.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11101111 (239 unsigned)
Bitwise arithmetic · Problem 0187
Calculate 111 − 141 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101111 and B=10001101.
- The unsigned values are A=111 and B=141.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001101 → 01110010.
- Add one to the inverted byte: 01110010 + 1 → 01110011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101111 + 01110011.
- Keep only the lowest eight bits: 11100010.
- Normal integers give 111−141=-30.
- After modulo 256, the result is 226.
- The signed interpretation of the output byte is -30.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11100010 (226 unsigned)
Bitwise arithmetic · Problem 0188
Calculate 111 − 249 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01101111 and B=11111001.
- The unsigned values are A=111 and B=249.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111001 → 00000110.
- Add one to the inverted byte: 00000110 + 1 → 00000111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01101111 + 00000111.
- Keep only the lowest eight bits: 01110110.
- Normal integers give 111−249=-138.
- After modulo 256, the result is 118.
- The signed interpretation of the output byte is 118.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01110110 (118 unsigned)
Bitwise arithmetic · Problem 0189
Calculate 112 − 59 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01110000 and B=00111011.
- The unsigned values are A=112 and B=59.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00111011 → 11000100.
- Add one to the inverted byte: 11000100 + 1 → 11000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01110000 + 11000101.
- Keep only the lowest eight bits: 00110101.
- Normal integers give 112−59=53.
- After modulo 256, the result is 53.
- The signed interpretation of the output byte is 53.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00110101 (53 unsigned)
Bitwise arithmetic · Problem 0190
Calculate 113 − 152 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01110001 and B=10011000.
- The unsigned values are A=113 and B=152.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011000 → 01100111.
- Add one to the inverted byte: 01100111 + 1 → 01101000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01110001 + 01101000.
- Keep only the lowest eight bits: 11011001.
- Normal integers give 113−152=-39.
- After modulo 256, the result is 217.
- The signed interpretation of the output byte is -39.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11011001 (217 unsigned)
Bitwise arithmetic · Problem 0191
Calculate 117 − 0 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01110101 and B=00000000.
- The unsigned values are A=117 and B=0.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000000 → 11111111.
- Add one to the inverted byte: 11111111 + 1 → 00000000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01110101 + 00000000.
- Keep only the lowest eight bits: 01110101.
- Normal integers give 117−0=117.
- After modulo 256, the result is 117.
- The signed interpretation of the output byte is 117.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01110101 (117 unsigned)
Bitwise arithmetic · Problem 0192
Calculate 117 − 53 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01110101 and B=00110101.
- The unsigned values are A=117 and B=53.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00110101 → 11001010.
- Add one to the inverted byte: 11001010 + 1 → 11001011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01110101 + 11001011.
- Keep only the lowest eight bits: 01000000.
- Normal integers give 117−53=64.
- After modulo 256, the result is 64.
- The signed interpretation of the output byte is 64.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01000000 (64 unsigned)