01How Computers Work

Fully solved problem book

Eight-bit subtraction

Set 11 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 0321

Calculate 190 − 116 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=10111110 and B=01110100.
  2. The unsigned values are A=190 and B=116.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01110100 → 10001011.
  5. Add one to the inverted byte: 10001011 + 1 → 10001100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 10111110 + 10001100.
  8. Keep only the lowest eight bits: 01001010.
  9. Normal integers give 190−116=74.
  10. After modulo 256, the result is 74.
  11. The signed interpretation of the output byte is 74.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 01001010 (74 unsigned)

Bitwise arithmetic · Problem 0322

Calculate 190 − 175 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=10111110 and B=10101111.
  2. The unsigned values are A=190 and B=175.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10101111 → 01010000.
  5. Add one to the inverted byte: 01010000 + 1 → 01010001.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 10111110 + 01010001.
  8. Keep only the lowest eight bits: 00001111.
  9. Normal integers give 190−175=15.
  10. After modulo 256, the result is 15.
  11. The signed interpretation of the output byte is 15.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00001111 (15 unsigned)

Bitwise arithmetic · Problem 0323

Calculate 190 − 198 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=10111110 and B=11000110.
  2. The unsigned values are A=190 and B=198.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11000110 → 00111001.
  5. Add one to the inverted byte: 00111001 + 1 → 00111010.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 10111110 + 00111010.
  8. Keep only the lowest eight bits: 11111000.
  9. Normal integers give 190−198=-8.
  10. After modulo 256, the result is 248.
  11. The signed interpretation of the output byte is -8.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 11111000 (248 unsigned)

Bitwise arithmetic · Problem 0324

Calculate 191 − 146 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=10111111 and B=10010010.
  2. The unsigned values are A=191 and B=146.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10010010 → 01101101.
  5. Add one to the inverted byte: 01101101 + 1 → 01101110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 10111111 + 01101110.
  8. Keep only the lowest eight bits: 00101101.
  9. Normal integers give 191−146=45.
  10. After modulo 256, the result is 45.
  11. The signed interpretation of the output byte is 45.
  12. 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 0325

Calculate 192 − 5 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000000 and B=00000101.
  2. The unsigned values are A=192 and B=5.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00000101 → 11111010.
  5. Add one to the inverted byte: 11111010 + 1 → 11111011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000000 + 11111011.
  8. Keep only the lowest eight bits: 10111011.
  9. Normal integers give 192−5=187.
  10. After modulo 256, the result is 187.
  11. The signed interpretation of the output byte is -69.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10111011 (187 unsigned)

Bitwise arithmetic · Problem 0326

Calculate 193 − 184 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000001 and B=10111000.
  2. The unsigned values are A=193 and B=184.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10111000 → 01000111.
  5. Add one to the inverted byte: 01000111 + 1 → 01001000.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000001 + 01001000.
  8. Keep only the lowest eight bits: 00001001.
  9. Normal integers give 193−184=9.
  10. After modulo 256, the result is 9.
  11. The signed interpretation of the output byte is 9.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00001001 (9 unsigned)

Bitwise arithmetic · Problem 0327

Calculate 194 − 104 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000010 and B=01101000.
  2. The unsigned values are A=194 and B=104.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01101000 → 10010111.
  5. Add one to the inverted byte: 10010111 + 1 → 10011000.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000010 + 10011000.
  8. Keep only the lowest eight bits: 01011010.
  9. Normal integers give 194−104=90.
  10. After modulo 256, the result is 90.
  11. The signed interpretation of the output byte is 90.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 01011010 (90 unsigned)

Bitwise arithmetic · Problem 0328

Calculate 195 − 235 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000011 and B=11101011.
  2. The unsigned values are A=195 and B=235.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11101011 → 00010100.
  5. Add one to the inverted byte: 00010100 + 1 → 00010101.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000011 + 00010101.
  8. Keep only the lowest eight bits: 11011000.
  9. Normal integers give 195−235=-40.
  10. After modulo 256, the result is 216.
  11. The signed interpretation of the output byte is -40.
  12. 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 0329

Calculate 198 − 166 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000110 and B=10100110.
  2. The unsigned values are A=198 and B=166.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10100110 → 01011001.
  5. Add one to the inverted byte: 01011001 + 1 → 01011010.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000110 + 01011010.
  8. Keep only the lowest eight bits: 00100000.
  9. Normal integers give 198−166=32.
  10. After modulo 256, the result is 32.
  11. The signed interpretation of the output byte is 32.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00100000 (32 unsigned)

Bitwise arithmetic · Problem 0330

Calculate 198 − 221 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000110 and B=11011101.
  2. The unsigned values are A=198 and B=221.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11011101 → 00100010.
  5. Add one to the inverted byte: 00100010 + 1 → 00100011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000110 + 00100011.
  8. Keep only the lowest eight bits: 11101001.
  9. Normal integers give 198−221=-23.
  10. After modulo 256, the result is 233.
  11. The signed interpretation of the output byte is -23.
  12. 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 0331

Calculate 199 − 61 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000111 and B=00111101.
  2. The unsigned values are A=199 and B=61.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00111101 → 11000010.
  5. Add one to the inverted byte: 11000010 + 1 → 11000011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000111 + 11000011.
  8. Keep only the lowest eight bits: 10001010.
  9. Normal integers give 199−61=138.
  10. After modulo 256, the result is 138.
  11. The signed interpretation of the output byte is -118.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10001010 (138 unsigned)

Bitwise arithmetic · Problem 0332

Calculate 199 − 193 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11000111 and B=11000001.
  2. The unsigned values are A=199 and B=193.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11000001 → 00111110.
  5. Add one to the inverted byte: 00111110 + 1 → 00111111.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11000111 + 00111111.
  8. Keep only the lowest eight bits: 00000110.
  9. Normal integers give 199−193=6.
  10. After modulo 256, the result is 6.
  11. The signed interpretation of the output byte is 6.
  12. 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 0333

Calculate 202 − 84 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001010 and B=01010100.
  2. The unsigned values are A=202 and B=84.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01010100 → 10101011.
  5. Add one to the inverted byte: 10101011 + 1 → 10101100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001010 + 10101100.
  8. Keep only the lowest eight bits: 01110110.
  9. Normal integers give 202−84=118.
  10. After modulo 256, the result is 118.
  11. The signed interpretation of the output byte is 118.
  12. 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 0334

Calculate 202 − 180 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001010 and B=10110100.
  2. The unsigned values are A=202 and B=180.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10110100 → 01001011.
  5. Add one to the inverted byte: 01001011 + 1 → 01001100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001010 + 01001100.
  8. Keep only the lowest eight bits: 00010110.
  9. Normal integers give 202−180=22.
  10. After modulo 256, the result is 22.
  11. The signed interpretation of the output byte is 22.
  12. 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 0335

Calculate 202 − 212 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001010 and B=11010100.
  2. The unsigned values are A=202 and B=212.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11010100 → 00101011.
  5. Add one to the inverted byte: 00101011 + 1 → 00101100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001010 + 00101100.
  8. Keep only the lowest eight bits: 11110110.
  9. Normal integers give 202−212=-10.
  10. After modulo 256, the result is 246.
  11. The signed interpretation of the output byte is -10.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 11110110 (246 unsigned)

Bitwise arithmetic · Problem 0336

Calculate 203 − 34 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001011 and B=00100010.
  2. The unsigned values are A=203 and B=34.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00100010 → 11011101.
  5. Add one to the inverted byte: 11011101 + 1 → 11011110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001011 + 11011110.
  8. Keep only the lowest eight bits: 10101001.
  9. Normal integers give 203−34=169.
  10. After modulo 256, the result is 169.
  11. The signed interpretation of the output byte is -87.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10101001 (169 unsigned)

Bitwise arithmetic · Problem 0337

Calculate 204 − 59 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001100 and B=00111011.
  2. The unsigned values are A=204 and B=59.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00111011 → 11000100.
  5. Add one to the inverted byte: 11000100 + 1 → 11000101.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001100 + 11000101.
  8. Keep only the lowest eight bits: 10010001.
  9. Normal integers give 204−59=145.
  10. After modulo 256, the result is 145.
  11. The signed interpretation of the output byte is -111.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10010001 (145 unsigned)

Bitwise arithmetic · Problem 0338

Calculate 204 − 128 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001100 and B=10000000.
  2. The unsigned values are A=204 and B=128.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10000000 → 01111111.
  5. Add one to the inverted byte: 01111111 + 1 → 10000000.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001100 + 10000000.
  8. Keep only the lowest eight bits: 01001100.
  9. Normal integers give 204−128=76.
  10. After modulo 256, the result is 76.
  11. The signed interpretation of the output byte is 76.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 01001100 (76 unsigned)

Bitwise arithmetic · Problem 0339

Calculate 204 − 140 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001100 and B=10001100.
  2. The unsigned values are A=204 and B=140.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10001100 → 01110011.
  5. Add one to the inverted byte: 01110011 + 1 → 01110100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001100 + 01110100.
  8. Keep only the lowest eight bits: 01000000.
  9. Normal integers give 204−140=64.
  10. After modulo 256, the result is 64.
  11. The signed interpretation of the output byte is 64.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 01000000 (64 unsigned)

Bitwise arithmetic · Problem 0340

Calculate 204 − 184 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001100 and B=10111000.
  2. The unsigned values are A=204 and B=184.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10111000 → 01000111.
  5. Add one to the inverted byte: 01000111 + 1 → 01001000.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001100 + 01001000.
  8. Keep only the lowest eight bits: 00010100.
  9. Normal integers give 204−184=20.
  10. After modulo 256, the result is 20.
  11. The signed interpretation of the output byte is 20.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00010100 (20 unsigned)

Bitwise arithmetic · Problem 0341

Calculate 205 − 74 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001101 and B=01001010.
  2. The unsigned values are A=205 and B=74.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01001010 → 10110101.
  5. Add one to the inverted byte: 10110101 + 1 → 10110110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001101 + 10110110.
  8. Keep only the lowest eight bits: 10000011.
  9. Normal integers give 205−74=131.
  10. After modulo 256, the result is 131.
  11. The signed interpretation of the output byte is -125.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10000011 (131 unsigned)

Bitwise arithmetic · Problem 0342

Calculate 205 − 168 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001101 and B=10101000.
  2. The unsigned values are A=205 and B=168.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10101000 → 01010111.
  5. Add one to the inverted byte: 01010111 + 1 → 01011000.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001101 + 01011000.
  8. Keep only the lowest eight bits: 00100101.
  9. Normal integers give 205−168=37.
  10. After modulo 256, the result is 37.
  11. The signed interpretation of the output byte is 37.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00100101 (37 unsigned)

Bitwise arithmetic · Problem 0343

Calculate 206 − 146 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001110 and B=10010010.
  2. The unsigned values are A=206 and B=146.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10010010 → 01101101.
  5. Add one to the inverted byte: 01101101 + 1 → 01101110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001110 + 01101110.
  8. Keep only the lowest eight bits: 00111100.
  9. Normal integers give 206−146=60.
  10. After modulo 256, the result is 60.
  11. The signed interpretation of the output byte is 60.
  12. 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 0344

Calculate 207 − 37 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001111 and B=00100101.
  2. The unsigned values are A=207 and B=37.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00100101 → 11011010.
  5. Add one to the inverted byte: 11011010 + 1 → 11011011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001111 + 11011011.
  8. Keep only the lowest eight bits: 10101010.
  9. Normal integers give 207−37=170.
  10. After modulo 256, the result is 170.
  11. The signed interpretation of the output byte is -86.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10101010 (170 unsigned)

Bitwise arithmetic · Problem 0345

Calculate 207 − 43 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11001111 and B=00101011.
  2. The unsigned values are A=207 and B=43.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00101011 → 11010100.
  5. Add one to the inverted byte: 11010100 + 1 → 11010101.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11001111 + 11010101.
  8. Keep only the lowest eight bits: 10100100.
  9. Normal integers give 207−43=164.
  10. After modulo 256, the result is 164.
  11. The signed interpretation of the output byte is -92.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10100100 (164 unsigned)

Bitwise arithmetic · Problem 0346

Calculate 208 − 37 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010000 and B=00100101.
  2. The unsigned values are A=208 and B=37.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00100101 → 11011010.
  5. Add one to the inverted byte: 11011010 + 1 → 11011011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010000 + 11011011.
  8. Keep only the lowest eight bits: 10101011.
  9. Normal integers give 208−37=171.
  10. After modulo 256, the result is 171.
  11. The signed interpretation of the output byte is -85.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10101011 (171 unsigned)

Bitwise arithmetic · Problem 0347

Calculate 210 − 227 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010010 and B=11100011.
  2. The unsigned values are A=210 and B=227.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11100011 → 00011100.
  5. Add one to the inverted byte: 00011100 + 1 → 00011101.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010010 + 00011101.
  8. Keep only the lowest eight bits: 11101111.
  9. Normal integers give 210−227=-17.
  10. After modulo 256, the result is 239.
  11. The signed interpretation of the output byte is -17.
  12. 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 0348

Calculate 211 − 74 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010011 and B=01001010.
  2. The unsigned values are A=211 and B=74.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01001010 → 10110101.
  5. Add one to the inverted byte: 10110101 + 1 → 10110110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010011 + 10110110.
  8. Keep only the lowest eight bits: 10001001.
  9. Normal integers give 211−74=137.
  10. After modulo 256, the result is 137.
  11. The signed interpretation of the output byte is -119.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 10001001 (137 unsigned)

Bitwise arithmetic · Problem 0349

Calculate 211 − 194 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010011 and B=11000010.
  2. The unsigned values are A=211 and B=194.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11000010 → 00111101.
  5. Add one to the inverted byte: 00111101 + 1 → 00111110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010011 + 00111110.
  8. Keep only the lowest eight bits: 00010001.
  9. Normal integers give 211−194=17.
  10. After modulo 256, the result is 17.
  11. The signed interpretation of the output byte is 17.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00010001 (17 unsigned)

Bitwise arithmetic · Problem 0350

Calculate 211 − 226 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010011 and B=11100010.
  2. The unsigned values are A=211 and B=226.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11100010 → 00011101.
  5. Add one to the inverted byte: 00011101 + 1 → 00011110.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010011 + 00011110.
  8. Keep only the lowest eight bits: 11110001.
  9. Normal integers give 211−226=-15.
  10. After modulo 256, the result is 241.
  11. The signed interpretation of the output byte is -15.
  12. 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 0351

Calculate 212 − 211 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010100 and B=11010011.
  2. The unsigned values are A=212 and B=211.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11010011 → 00101100.
  5. Add one to the inverted byte: 00101100 + 1 → 00101101.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010100 + 00101101.
  8. Keep only the lowest eight bits: 00000001.
  9. Normal integers give 212−211=1.
  10. After modulo 256, the result is 1.
  11. The signed interpretation of the output byte is 1.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 00000001 (1 unsigned)

Bitwise arithmetic · Problem 0352

Calculate 212 − 225 in eight-bit modular arithmetic.

Try it on paper first. The worked answer is hidden below.

Reveal detailed solution →
  1. Start with A=11010100 and B=11100001.
  2. The unsigned values are A=212 and B=225.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11100001 → 00011110.
  5. Add one to the inverted byte: 00011110 + 1 → 00011111.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 11010100 + 00011111.
  8. Keep only the lowest eight bits: 11110011.
  9. Normal integers give 212−225=-13.
  10. After modulo 256, the result is 243.
  11. The signed interpretation of the output byte is -13.
  12. Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.

Final answer: 11110011 (243 unsigned)