Fully solved problem book
Eight-bit subtraction
Set 12 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 0353
Calculate 212 − 230 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11010100 and B=11100110.
- The unsigned values are A=212 and B=230.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100110 → 00011001.
- Add one to the inverted byte: 00011001 + 1 → 00011010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11010100 + 00011010.
- Keep only the lowest eight bits: 11101110.
- Normal integers give 212−230=-18.
- After modulo 256, the result is 238.
- The signed interpretation of the output byte is -18.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11101110 (238 unsigned)
Bitwise arithmetic · Problem 0354
Calculate 215 − 65 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11010111 and B=01000001.
- The unsigned values are A=215 and B=65.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01000001 → 10111110.
- Add one to the inverted byte: 10111110 + 1 → 10111111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11010111 + 10111111.
- Keep only the lowest eight bits: 10010110.
- Normal integers give 215−65=150.
- After modulo 256, the result is 150.
- The signed interpretation of the output byte is -106.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10010110 (150 unsigned)
Bitwise arithmetic · Problem 0355
Calculate 215 − 182 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11010111 and B=10110110.
- The unsigned values are A=215 and B=182.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110110 → 01001001.
- Add one to the inverted byte: 01001001 + 1 → 01001010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11010111 + 01001010.
- Keep only the lowest eight bits: 00100001.
- Normal integers give 215−182=33.
- After modulo 256, the result is 33.
- The signed interpretation of the output byte is 33.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00100001 (33 unsigned)
Bitwise arithmetic · Problem 0356
Calculate 216 − 93 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011000 and B=01011101.
- The unsigned values are A=216 and B=93.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01011101 → 10100010.
- Add one to the inverted byte: 10100010 + 1 → 10100011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011000 + 10100011.
- Keep only the lowest eight bits: 01111011.
- Normal integers give 216−93=123.
- After modulo 256, the result is 123.
- 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: 01111011 (123 unsigned)
Bitwise arithmetic · Problem 0357
Calculate 217 − 142 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011001 and B=10001110.
- The unsigned values are A=217 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: 11011001 + 01110010.
- Keep only the lowest eight bits: 01001011.
- Normal integers give 217−142=75.
- After modulo 256, the result is 75.
- The signed interpretation of the output byte is 75.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01001011 (75 unsigned)
Bitwise arithmetic · Problem 0358
Calculate 217 − 155 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011001 and B=10011011.
- The unsigned values are A=217 and B=155.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011011 → 01100100.
- Add one to the inverted byte: 01100100 + 1 → 01100101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011001 + 01100101.
- Keep only the lowest eight bits: 00111110.
- Normal integers give 217−155=62.
- After modulo 256, the result is 62.
- The signed interpretation of the output byte is 62.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00111110 (62 unsigned)
Bitwise arithmetic · Problem 0359
Calculate 217 − 233 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011001 and B=11101001.
- The unsigned values are A=217 and B=233.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101001 → 00010110.
- Add one to the inverted byte: 00010110 + 1 → 00010111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011001 + 00010111.
- Keep only the lowest eight bits: 11110000.
- Normal integers give 217−233=-16.
- After modulo 256, the result is 240.
- The signed interpretation of the output byte is -16.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11110000 (240 unsigned)
Bitwise arithmetic · Problem 0360
Calculate 217 − 241 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011001 and B=11110001.
- The unsigned values are A=217 and B=241.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110001 → 00001110.
- Add one to the inverted byte: 00001110 + 1 → 00001111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011001 + 00001111.
- Keep only the lowest eight bits: 11101000.
- Normal integers give 217−241=-24.
- After modulo 256, the result is 232.
- The signed interpretation of the output byte is -24.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11101000 (232 unsigned)
Bitwise arithmetic · Problem 0361
Calculate 218 − 86 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011010 and B=01010110.
- The unsigned values are A=218 and B=86.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010110 → 10101001.
- Add one to the inverted byte: 10101001 + 1 → 10101010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011010 + 10101010.
- Keep only the lowest eight bits: 10000100.
- Normal integers give 218−86=132.
- After modulo 256, the result is 132.
- The signed interpretation of the output byte is -124.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10000100 (132 unsigned)
Bitwise arithmetic · Problem 0362
Calculate 218 − 202 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011010 and B=11001010.
- The unsigned values are A=218 and B=202.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11001010 → 00110101.
- Add one to the inverted byte: 00110101 + 1 → 00110110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011010 + 00110110.
- Keep only the lowest eight bits: 00010000.
- Normal integers give 218−202=16.
- After modulo 256, the result is 16.
- The signed interpretation of the output byte is 16.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00010000 (16 unsigned)
Bitwise arithmetic · Problem 0363
Calculate 219 − 33 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011011 and B=00100001.
- The unsigned values are A=219 and B=33.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100001 → 11011110.
- Add one to the inverted byte: 11011110 + 1 → 11011111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011011 + 11011111.
- Keep only the lowest eight bits: 10111010.
- Normal integers give 219−33=186.
- After modulo 256, the result is 186.
- The signed interpretation of the output byte is -70.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10111010 (186 unsigned)
Bitwise arithmetic · Problem 0364
Calculate 219 − 87 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011011 and B=01010111.
- The unsigned values are A=219 and B=87.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010111 → 10101000.
- Add one to the inverted byte: 10101000 + 1 → 10101001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011011 + 10101001.
- Keep only the lowest eight bits: 10000100.
- Normal integers give 219−87=132.
- After modulo 256, the result is 132.
- The signed interpretation of the output byte is -124.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10000100 (132 unsigned)
Bitwise arithmetic · Problem 0365
Calculate 219 − 228 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011011 and B=11100100.
- The unsigned values are A=219 and B=228.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100100 → 00011011.
- Add one to the inverted byte: 00011011 + 1 → 00011100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011011 + 00011100.
- Keep only the lowest eight bits: 11110111.
- Normal integers give 219−228=-9.
- After modulo 256, the result is 247.
- The signed interpretation of the output byte is -9.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11110111 (247 unsigned)
Bitwise arithmetic · Problem 0366
Calculate 219 − 242 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011011 and B=11110010.
- The unsigned values are A=219 and B=242.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110010 → 00001101.
- Add one to the inverted byte: 00001101 + 1 → 00001110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011011 + 00001110.
- Keep only the lowest eight bits: 11101001.
- Normal integers give 219−242=-23.
- After modulo 256, the result is 233.
- 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: 11101001 (233 unsigned)
Bitwise arithmetic · Problem 0367
Calculate 220 − 142 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011100 and B=10001110.
- The unsigned values are A=220 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: 11011100 + 01110010.
- Keep only the lowest eight bits: 01001110.
- Normal integers give 220−142=78.
- After modulo 256, the result is 78.
- The signed interpretation of the output byte is 78.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01001110 (78 unsigned)
Bitwise arithmetic · Problem 0368
Calculate 220 − 194 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011100 and B=11000010.
- The unsigned values are A=220 and B=194.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11000010 → 00111101.
- Add one to the inverted byte: 00111101 + 1 → 00111110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011100 + 00111110.
- Keep only the lowest eight bits: 00011010.
- Normal integers give 220−194=26.
- After modulo 256, the result is 26.
- The signed interpretation of the output byte is 26.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00011010 (26 unsigned)
Bitwise arithmetic · Problem 0369
Calculate 220 − 255 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011100 and B=11111111.
- The unsigned values are A=220 and B=255.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111111 → 00000000.
- Add one to the inverted byte: 00000000 + 1 → 00000001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011100 + 00000001.
- Keep only the lowest eight bits: 11011101.
- Normal integers give 220−255=-35.
- After modulo 256, the result is 221.
- The signed interpretation of the output byte is -35.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11011101 (221 unsigned)
Bitwise arithmetic · Problem 0370
Calculate 221 − 178 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011101 and B=10110010.
- The unsigned values are A=221 and B=178.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110010 → 01001101.
- Add one to the inverted byte: 01001101 + 1 → 01001110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011101 + 01001110.
- Keep only the lowest eight bits: 00101011.
- Normal integers give 221−178=43.
- After modulo 256, the result is 43.
- The signed interpretation of the output byte is 43.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00101011 (43 unsigned)
Bitwise arithmetic · Problem 0371
Calculate 221 − 215 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011101 and B=11010111.
- The unsigned values are A=221 and B=215.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11010111 → 00101000.
- Add one to the inverted byte: 00101000 + 1 → 00101001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011101 + 00101001.
- Keep only the lowest eight bits: 00000110.
- Normal integers give 221−215=6.
- After modulo 256, the result is 6.
- The signed interpretation of the output byte is 6.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00000110 (6 unsigned)
Bitwise arithmetic · Problem 0372
Calculate 222 − 119 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011110 and B=01110111.
- The unsigned values are A=222 and B=119.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01110111 → 10001000.
- Add one to the inverted byte: 10001000 + 1 → 10001001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011110 + 10001001.
- Keep only the lowest eight bits: 01100111.
- Normal integers give 222−119=103.
- After modulo 256, the result is 103.
- The signed interpretation of the output byte is 103.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01100111 (103 unsigned)
Bitwise arithmetic · Problem 0373
Calculate 223 − 12 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011111 and B=00001100.
- The unsigned values are A=223 and B=12.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001100 → 11110011.
- Add one to the inverted byte: 11110011 + 1 → 11110100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011111 + 11110100.
- Keep only the lowest eight bits: 11010011.
- Normal integers give 223−12=211.
- After modulo 256, the result is 211.
- 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: 11010011 (211 unsigned)
Bitwise arithmetic · Problem 0374
Calculate 223 − 42 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11011111 and B=00101010.
- The unsigned values are A=223 and B=42.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00101010 → 11010101.
- Add one to the inverted byte: 11010101 + 1 → 11010110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11011111 + 11010110.
- Keep only the lowest eight bits: 10110101.
- Normal integers give 223−42=181.
- After modulo 256, the result is 181.
- The signed interpretation of the output byte is -75.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110101 (181 unsigned)
Bitwise arithmetic · Problem 0375
Calculate 225 − 222 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100001 and B=11011110.
- The unsigned values are A=225 and B=222.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11011110 → 00100001.
- Add one to the inverted byte: 00100001 + 1 → 00100010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100001 + 00100010.
- Keep only the lowest eight bits: 00000011.
- Normal integers give 225−222=3.
- After modulo 256, the result is 3.
- The signed interpretation of the output byte is 3.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00000011 (3 unsigned)
Bitwise arithmetic · Problem 0376
Calculate 226 − 135 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100010 and B=10000111.
- The unsigned values are A=226 and B=135.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10000111 → 01111000.
- Add one to the inverted byte: 01111000 + 1 → 01111001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100010 + 01111001.
- Keep only the lowest eight bits: 01011011.
- Normal integers give 226−135=91.
- After modulo 256, the result is 91.
- The signed interpretation of the output byte is 91.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01011011 (91 unsigned)
Bitwise arithmetic · Problem 0377
Calculate 229 − 118 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100101 and B=01110110.
- The unsigned values are A=229 and B=118.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01110110 → 10001001.
- Add one to the inverted byte: 10001001 + 1 → 10001010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100101 + 10001010.
- Keep only the lowest eight bits: 01101111.
- Normal integers give 229−118=111.
- After modulo 256, the result is 111.
- The signed interpretation of the output byte is 111.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01101111 (111 unsigned)
Bitwise arithmetic · Problem 0378
Calculate 230 − 128 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100110 and B=10000000.
- The unsigned values are A=230 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: 11100110 + 10000000.
- Keep only the lowest eight bits: 01100110.
- Normal integers give 230−128=102.
- After modulo 256, the result is 102.
- The signed interpretation of the output byte is 102.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01100110 (102 unsigned)
Bitwise arithmetic · Problem 0379
Calculate 230 − 170 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100110 and B=10101010.
- The unsigned values are A=230 and B=170.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10101010 → 01010101.
- Add one to the inverted byte: 01010101 + 1 → 01010110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100110 + 01010110.
- Keep only the lowest eight bits: 00111100.
- Normal integers give 230−170=60.
- After modulo 256, the result is 60.
- The signed interpretation of the output byte is 60.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00111100 (60 unsigned)
Bitwise arithmetic · Problem 0380
Calculate 230 − 245 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100110 and B=11110101.
- The unsigned values are A=230 and B=245.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110101 → 00001010.
- Add one to the inverted byte: 00001010 + 1 → 00001011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100110 + 00001011.
- Keep only the lowest eight bits: 11110001.
- Normal integers give 230−245=-15.
- After modulo 256, the result is 241.
- The signed interpretation of the output byte is -15.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11110001 (241 unsigned)
Bitwise arithmetic · Problem 0381
Calculate 231 − 15 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100111 and B=00001111.
- The unsigned values are A=231 and B=15.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001111 → 11110000.
- Add one to the inverted byte: 11110000 + 1 → 11110001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100111 + 11110001.
- Keep only the lowest eight bits: 11011000.
- Normal integers give 231−15=216.
- After modulo 256, the result is 216.
- The signed interpretation of the output byte is -40.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11011000 (216 unsigned)
Bitwise arithmetic · Problem 0382
Calculate 231 − 108 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100111 and B=01101100.
- The unsigned values are A=231 and B=108.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01101100 → 10010011.
- Add one to the inverted byte: 10010011 + 1 → 10010100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100111 + 10010100.
- Keep only the lowest eight bits: 01111011.
- Normal integers give 231−108=123.
- After modulo 256, the result is 123.
- 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: 01111011 (123 unsigned)
Bitwise arithmetic · Problem 0383
Calculate 231 − 139 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11100111 and B=10001011.
- The unsigned values are A=231 and B=139.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001011 → 01110100.
- Add one to the inverted byte: 01110100 + 1 → 01110101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11100111 + 01110101.
- Keep only the lowest eight bits: 01011100.
- Normal integers give 231−139=92.
- After modulo 256, the result is 92.
- The signed interpretation of the output byte is 92.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01011100 (92 unsigned)
Bitwise arithmetic · Problem 0384
Calculate 232 − 107 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11101000 and B=01101011.
- The unsigned values are A=232 and B=107.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01101011 → 10010100.
- Add one to the inverted byte: 10010100 + 1 → 10010101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11101000 + 10010101.
- Keep only the lowest eight bits: 01111101.
- Normal integers give 232−107=125.
- After modulo 256, the result is 125.
- The signed interpretation of the output byte is 125.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01111101 (125 unsigned)