Fully solved problem book
Eight-bit subtraction
Set 14 of 14 · 4 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 0417
Calculate 253 − 126 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11111101 and B=01111110.
- The unsigned values are A=253 and B=126.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01111110 → 10000001.
- Add one to the inverted byte: 10000001 + 1 → 10000010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11111101 + 10000010.
- Keep only the lowest eight bits: 01111111.
- Normal integers give 253−126=127.
- After modulo 256, the result is 127.
- The signed interpretation of the output byte is 127.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01111111 (127 unsigned)
Bitwise arithmetic · Problem 0418
Calculate 253 − 136 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11111101 and B=10001000.
- The unsigned values are A=253 and B=136.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001000 → 01110111.
- Add one to the inverted byte: 01110111 + 1 → 01111000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11111101 + 01111000.
- Keep only the lowest eight bits: 01110101.
- Normal integers give 253−136=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 0419
Calculate 254 − 176 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11111110 and B=10110000.
- The unsigned values are A=254 and B=176.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110000 → 01001111.
- Add one to the inverted byte: 01001111 + 1 → 01010000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11111110 + 01010000.
- Keep only the lowest eight bits: 01001110.
- Normal integers give 254−176=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 0420
Calculate 255 − 213 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=11111111 and B=11010101.
- The unsigned values are A=255 and B=213.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11010101 → 00101010.
- Add one to the inverted byte: 00101010 + 1 → 00101011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 11111111 + 00101011.
- Keep only the lowest eight bits: 00101010.
- Normal integers give 255−213=42.
- After modulo 256, the result is 42.
- 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: 00101010 (42 unsigned)