01How Computers Work

Fully solved problem book

Eight-bit subtraction

Set 5 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 0129

Calculate 79 − 38 in eight-bit modular arithmetic.

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

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

Final answer: 00101001 (41 unsigned)

Bitwise arithmetic · Problem 0130

Calculate 79 − 44 in eight-bit modular arithmetic.

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

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

Final answer: 00100011 (35 unsigned)

Bitwise arithmetic · Problem 0131

Calculate 79 − 54 in eight-bit modular arithmetic.

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

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

Final answer: 00011001 (25 unsigned)

Bitwise arithmetic · Problem 0132

Calculate 79 − 136 in eight-bit modular arithmetic.

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

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

Final answer: 11000111 (199 unsigned)

Bitwise arithmetic · Problem 0133

Calculate 79 − 204 in eight-bit modular arithmetic.

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

Reveal detailed solution →
  1. Start with A=01001111 and B=11001100.
  2. The unsigned values are A=79 and B=204.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 11001100 → 00110011.
  5. Add one to the inverted byte: 00110011 + 1 → 00110100.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 01001111 + 00110100.
  8. Keep only the lowest eight bits: 10000011.
  9. Normal integers give 79−204=-125.
  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 0134

Calculate 79 − 247 in eight-bit modular arithmetic.

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

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

Final answer: 01011000 (88 unsigned)

Bitwise arithmetic · Problem 0135

Calculate 81 − 230 in eight-bit modular arithmetic.

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

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

Final answer: 01101011 (107 unsigned)

Bitwise arithmetic · Problem 0136

Calculate 82 − 148 in eight-bit modular arithmetic.

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

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

Final answer: 10111110 (190 unsigned)

Bitwise arithmetic · Problem 0137

Calculate 82 − 189 in eight-bit modular arithmetic.

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

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

Final answer: 10010101 (149 unsigned)

Bitwise arithmetic · Problem 0138

Calculate 82 − 242 in eight-bit modular arithmetic.

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

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

Final answer: 01100000 (96 unsigned)

Bitwise arithmetic · Problem 0139

Calculate 83 − 191 in eight-bit modular arithmetic.

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

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

Final answer: 10010100 (148 unsigned)

Bitwise arithmetic · Problem 0140

Calculate 83 − 219 in eight-bit modular arithmetic.

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

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

Calculate 84 − 121 in eight-bit modular arithmetic.

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

Reveal detailed solution →
  1. Start with A=01010100 and B=01111001.
  2. The unsigned values are A=84 and B=121.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 01111001 → 10000110.
  5. Add one to the inverted byte: 10000110 + 1 → 10000111.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 01010100 + 10000111.
  8. Keep only the lowest eight bits: 11011011.
  9. Normal integers give 84−121=-37.
  10. After modulo 256, the result is 219.
  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: 11011011 (219 unsigned)

Bitwise arithmetic · Problem 0142

Calculate 85 − 9 in eight-bit modular arithmetic.

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

Reveal detailed solution →
  1. Start with A=01010101 and B=00001001.
  2. The unsigned values are A=85 and B=9.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 00001001 → 11110110.
  5. Add one to the inverted byte: 11110110 + 1 → 11110111.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 01010101 + 11110111.
  8. Keep only the lowest eight bits: 01001100.
  9. Normal integers give 85−9=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 0143

Calculate 86 − 3 in eight-bit modular arithmetic.

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

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

Final answer: 01010011 (83 unsigned)

Bitwise arithmetic · Problem 0144

Calculate 86 − 23 in eight-bit modular arithmetic.

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

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

Final answer: 00111111 (63 unsigned)

Bitwise arithmetic · Problem 0145

Calculate 86 − 111 in eight-bit modular arithmetic.

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

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

Final answer: 11100111 (231 unsigned)

Bitwise arithmetic · Problem 0146

Calculate 86 − 222 in eight-bit modular arithmetic.

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

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

Calculate 86 − 229 in eight-bit modular arithmetic.

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

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

Final answer: 01110001 (113 unsigned)

Bitwise arithmetic · Problem 0148

Calculate 86 − 237 in eight-bit modular arithmetic.

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

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

Final answer: 01101001 (105 unsigned)

Bitwise arithmetic · Problem 0149

Calculate 87 − 169 in eight-bit modular arithmetic.

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

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

Final answer: 10101110 (174 unsigned)

Bitwise arithmetic · Problem 0150

Calculate 88 − 39 in eight-bit modular arithmetic.

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

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

Final answer: 00110001 (49 unsigned)

Bitwise arithmetic · Problem 0151

Calculate 89 − 64 in eight-bit modular arithmetic.

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

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

Final answer: 00011001 (25 unsigned)

Bitwise arithmetic · Problem 0152

Calculate 89 − 154 in eight-bit modular arithmetic.

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

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

Final answer: 10111111 (191 unsigned)

Bitwise arithmetic · Problem 0153

Calculate 89 − 181 in eight-bit modular arithmetic.

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

Reveal detailed solution →
  1. Start with A=01011001 and B=10110101.
  2. The unsigned values are A=89 and B=181.
  3. Rewrite subtraction as A + (NOT B) + 1.
  4. Invert every bit of B: 10110101 → 01001010.
  5. Add one to the inverted byte: 01001010 + 1 → 01001011.
  6. This new byte represents the modular additive inverse of B.
  7. Add A and modular −B: 01011001 + 01001011.
  8. Keep only the lowest eight bits: 10100100.
  9. Normal integers give 89−181=-92.
  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 0154

Calculate 90 − 90 in eight-bit modular arithmetic.

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

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

Final answer: 00000000 (0 unsigned)

Bitwise arithmetic · Problem 0155

Calculate 90 − 206 in eight-bit modular arithmetic.

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

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

Final answer: 10001100 (140 unsigned)

Bitwise arithmetic · Problem 0156

Calculate 91 − 25 in eight-bit modular arithmetic.

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

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

Final answer: 01000010 (66 unsigned)

Bitwise arithmetic · Problem 0157

Calculate 91 − 86 in eight-bit modular arithmetic.

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

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

Final answer: 00000101 (5 unsigned)

Bitwise arithmetic · Problem 0158

Calculate 91 − 132 in eight-bit modular arithmetic.

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

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

Final answer: 11010111 (215 unsigned)

Bitwise arithmetic · Problem 0159

Calculate 92 − 20 in eight-bit modular arithmetic.

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

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

Final answer: 01001000 (72 unsigned)

Bitwise arithmetic · Problem 0160

Calculate 93 − 114 in eight-bit modular arithmetic.

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

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

Final answer: 11101011 (235 unsigned)