Fully solved problem book
Eight-bit subtraction
Set 1 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 0001
Calculate 0 − 180 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000000 and B=10110100.
- The unsigned values are A=0 and B=180.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110100 → 01001011.
- Add one to the inverted byte: 01001011 + 1 → 01001100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000000 + 01001100.
- Keep only the lowest eight bits: 01001100.
- Normal integers give 0−180=-180.
- After modulo 256, the result is 76.
- The signed interpretation of the output byte is 76.
- 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 0002
Calculate 0 − 198 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000000 and B=11000110.
- The unsigned values are A=0 and B=198.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11000110 → 00111001.
- Add one to the inverted byte: 00111001 + 1 → 00111010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000000 + 00111010.
- Keep only the lowest eight bits: 00111010.
- Normal integers give 0−198=-198.
- After modulo 256, the result is 58.
- The signed interpretation of the output byte is 58.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00111010 (58 unsigned)
Bitwise arithmetic · Problem 0003
Calculate 0 − 200 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000000 and B=11001000.
- The unsigned values are A=0 and B=200.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11001000 → 00110111.
- Add one to the inverted byte: 00110111 + 1 → 00111000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000000 + 00111000.
- Keep only the lowest eight bits: 00111000.
- Normal integers give 0−200=-200.
- After modulo 256, the result is 56.
- The signed interpretation of the output byte is 56.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00111000 (56 unsigned)
Bitwise arithmetic · Problem 0004
Calculate 0 − 204 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000000 and B=11001100.
- The unsigned values are A=0 and B=204.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11001100 → 00110011.
- Add one to the inverted byte: 00110011 + 1 → 00110100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000000 + 00110100.
- Keep only the lowest eight bits: 00110100.
- Normal integers give 0−204=-204.
- After modulo 256, the result is 52.
- The signed interpretation of the output byte is 52.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00110100 (52 unsigned)
Bitwise arithmetic · Problem 0005
Calculate 0 − 238 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000000 and B=11101110.
- The unsigned values are A=0 and B=238.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101110 → 00010001.
- Add one to the inverted byte: 00010001 + 1 → 00010010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000000 + 00010010.
- Keep only the lowest eight bits: 00010010.
- Normal integers give 0−238=-238.
- After modulo 256, the result is 18.
- 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: 00010010 (18 unsigned)
Bitwise arithmetic · Problem 0006
Calculate 1 − 14 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=00001110.
- The unsigned values are A=1 and B=14.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001110 → 11110001.
- Add one to the inverted byte: 11110001 + 1 → 11110010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000001 + 11110010.
- Keep only the lowest eight bits: 11110011.
- Normal integers give 1−14=-13.
- After modulo 256, the result is 243.
- 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: 11110011 (243 unsigned)
Bitwise arithmetic · Problem 0007
Calculate 1 − 50 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=00110010.
- The unsigned values are A=1 and B=50.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00110010 → 11001101.
- Add one to the inverted byte: 11001101 + 1 → 11001110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000001 + 11001110.
- Keep only the lowest eight bits: 11001111.
- Normal integers give 1−50=-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 0008
Calculate 1 − 93 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=01011101.
- The unsigned values are A=1 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: 00000001 + 10100011.
- Keep only the lowest eight bits: 10100100.
- Normal integers give 1−93=-92.
- After modulo 256, the result is 164.
- 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: 10100100 (164 unsigned)
Bitwise arithmetic · Problem 0009
Calculate 1 − 174 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=10101110.
- The unsigned values are A=1 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: 00000001 + 01010010.
- Keep only the lowest eight bits: 01010011.
- Normal integers give 1−174=-173.
- After modulo 256, the result is 83.
- The signed interpretation of the output byte is 83.
- 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 0010
Calculate 1 − 250 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=11111010.
- The unsigned values are A=1 and B=250.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111010 → 00000101.
- Add one to the inverted byte: 00000101 + 1 → 00000110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000001 + 00000110.
- Keep only the lowest eight bits: 00000111.
- Normal integers give 1−250=-249.
- After modulo 256, the result is 7.
- The signed interpretation of the output byte is 7.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00000111 (7 unsigned)
Bitwise arithmetic · Problem 0011
Calculate 1 − 253 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000001 and B=11111101.
- The unsigned values are A=1 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: 00000001 + 00000011.
- Keep only the lowest eight bits: 00000100.
- Normal integers give 1−253=-252.
- After modulo 256, the result is 4.
- The signed interpretation of the output byte is 4.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00000100 (4 unsigned)
Bitwise arithmetic · Problem 0012
Calculate 2 − 76 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000010 and B=01001100.
- The unsigned values are A=2 and B=76.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01001100 → 10110011.
- Add one to the inverted byte: 10110011 + 1 → 10110100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000010 + 10110100.
- Keep only the lowest eight bits: 10110110.
- Normal integers give 2−76=-74.
- After modulo 256, the result is 182.
- The signed interpretation of the output byte is -74.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110110 (182 unsigned)
Bitwise arithmetic · Problem 0013
Calculate 3 − 209 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000011 and B=11010001.
- The unsigned values are A=3 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: 00000011 + 00101111.
- Keep only the lowest eight bits: 00110010.
- Normal integers give 3−209=-206.
- After modulo 256, the result is 50.
- 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: 00110010 (50 unsigned)
Bitwise arithmetic · Problem 0014
Calculate 5 − 112 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000101 and B=01110000.
- The unsigned values are A=5 and B=112.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01110000 → 10001111.
- Add one to the inverted byte: 10001111 + 1 → 10010000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000101 + 10010000.
- Keep only the lowest eight bits: 10010101.
- Normal integers give 5−112=-107.
- After modulo 256, the result is 149.
- The signed interpretation of the output byte is -107.
- 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 0015
Calculate 5 − 225 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000101 and B=11100001.
- The unsigned values are A=5 and B=225.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100001 → 00011110.
- Add one to the inverted byte: 00011110 + 1 → 00011111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000101 + 00011111.
- Keep only the lowest eight bits: 00100100.
- Normal integers give 5−225=-220.
- After modulo 256, the result is 36.
- The signed interpretation of the output byte is 36.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00100100 (36 unsigned)
Bitwise arithmetic · Problem 0016
Calculate 6 − 74 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000110 and B=01001010.
- The unsigned values are A=6 and B=74.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01001010 → 10110101.
- Add one to the inverted byte: 10110101 + 1 → 10110110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000110 + 10110110.
- Keep only the lowest eight bits: 10111100.
- Normal integers give 6−74=-68.
- After modulo 256, the result is 188.
- The signed interpretation of the output byte is -68.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10111100 (188 unsigned)
Bitwise arithmetic · Problem 0017
Calculate 6 − 138 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000110 and B=10001010.
- The unsigned values are A=6 and B=138.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001010 → 01110101.
- Add one to the inverted byte: 01110101 + 1 → 01110110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000110 + 01110110.
- Keep only the lowest eight bits: 01111100.
- Normal integers give 6−138=-132.
- After modulo 256, the result is 124.
- 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: 01111100 (124 unsigned)
Bitwise arithmetic · Problem 0018
Calculate 6 − 244 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000110 and B=11110100.
- The unsigned values are A=6 and B=244.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110100 → 00001011.
- Add one to the inverted byte: 00001011 + 1 → 00001100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000110 + 00001100.
- Keep only the lowest eight bits: 00010010.
- Normal integers give 6−244=-238.
- After modulo 256, the result is 18.
- 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: 00010010 (18 unsigned)
Bitwise arithmetic · Problem 0019
Calculate 7 − 44 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000111 and B=00101100.
- The unsigned values are A=7 and B=44.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00101100 → 11010011.
- Add one to the inverted byte: 11010011 + 1 → 11010100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000111 + 11010100.
- Keep only the lowest eight bits: 11011011.
- Normal integers give 7−44=-37.
- After modulo 256, the result is 219.
- The signed interpretation of the output byte is -37.
- 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 0020
Calculate 7 − 161 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00000111 and B=10100001.
- The unsigned values are A=7 and B=161.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10100001 → 01011110.
- Add one to the inverted byte: 01011110 + 1 → 01011111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00000111 + 01011111.
- Keep only the lowest eight bits: 01100110.
- Normal integers give 7−161=-154.
- 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 0021
Calculate 8 − 7 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001000 and B=00000111.
- The unsigned values are A=8 and B=7.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000111 → 11111000.
- Add one to the inverted byte: 11111000 + 1 → 11111001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001000 + 11111001.
- Keep only the lowest eight bits: 00000001.
- Normal integers give 8−7=1.
- After modulo 256, the result is 1.
- The signed interpretation of the output byte is 1.
- 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 0022
Calculate 8 − 90 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001000 and B=01011010.
- The unsigned values are A=8 and B=90.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01011010 → 10100101.
- Add one to the inverted byte: 10100101 + 1 → 10100110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001000 + 10100110.
- Keep only the lowest eight bits: 10101110.
- Normal integers give 8−90=-82.
- After modulo 256, the result is 174.
- The signed interpretation of the output byte is -82.
- 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 0023
Calculate 8 − 151 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001000 and B=10010111.
- The unsigned values are A=8 and B=151.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10010111 → 01101000.
- Add one to the inverted byte: 01101000 + 1 → 01101001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001000 + 01101001.
- Keep only the lowest eight bits: 01110001.
- Normal integers give 8−151=-143.
- After modulo 256, the result is 113.
- The signed interpretation of the output byte is 113.
- 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 0024
Calculate 8 − 236 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001000 and B=11101100.
- The unsigned values are A=8 and B=236.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101100 → 00010011.
- Add one to the inverted byte: 00010011 + 1 → 00010100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001000 + 00010100.
- Keep only the lowest eight bits: 00011100.
- Normal integers give 8−236=-228.
- After modulo 256, the result is 28.
- The signed interpretation of the output byte is 28.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00011100 (28 unsigned)
Bitwise arithmetic · Problem 0025
Calculate 8 − 243 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001000 and B=11110011.
- The unsigned values are A=8 and B=243.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110011 → 00001100.
- Add one to the inverted byte: 00001100 + 1 → 00001101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001000 + 00001101.
- Keep only the lowest eight bits: 00010101.
- Normal integers give 8−243=-235.
- After modulo 256, the result is 21.
- The signed interpretation of the output byte is 21.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00010101 (21 unsigned)
Bitwise arithmetic · Problem 0026
Calculate 9 − 2 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001001 and B=00000010.
- The unsigned values are A=9 and B=2.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000010 → 11111101.
- Add one to the inverted byte: 11111101 + 1 → 11111110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001001 + 11111110.
- Keep only the lowest eight bits: 00000111.
- Normal integers give 9−2=7.
- After modulo 256, the result is 7.
- The signed interpretation of the output byte is 7.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00000111 (7 unsigned)
Bitwise arithmetic · Problem 0027
Calculate 9 − 169 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001001 and B=10101001.
- The unsigned values are A=9 and B=169.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10101001 → 01010110.
- Add one to the inverted byte: 01010110 + 1 → 01010111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001001 + 01010111.
- Keep only the lowest eight bits: 01100000.
- Normal integers give 9−169=-160.
- After modulo 256, the result is 96.
- 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: 01100000 (96 unsigned)
Bitwise arithmetic · Problem 0028
Calculate 9 − 180 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001001 and B=10110100.
- The unsigned values are A=9 and B=180.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110100 → 01001011.
- Add one to the inverted byte: 01001011 + 1 → 01001100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001001 + 01001100.
- Keep only the lowest eight bits: 01010101.
- Normal integers give 9−180=-171.
- After modulo 256, the result is 85.
- The signed interpretation of the output byte is 85.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01010101 (85 unsigned)
Bitwise arithmetic · Problem 0029
Calculate 9 − 198 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001001 and B=11000110.
- The unsigned values are A=9 and B=198.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11000110 → 00111001.
- Add one to the inverted byte: 00111001 + 1 → 00111010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001001 + 00111010.
- Keep only the lowest eight bits: 01000011.
- Normal integers give 9−198=-189.
- After modulo 256, the result is 67.
- 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: 01000011 (67 unsigned)
Bitwise arithmetic · Problem 0030
Calculate 12 − 175 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001100 and B=10101111.
- The unsigned values are A=12 and B=175.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10101111 → 01010000.
- Add one to the inverted byte: 01010000 + 1 → 01010001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001100 + 01010001.
- Keep only the lowest eight bits: 01011101.
- Normal integers give 12−175=-163.
- After modulo 256, the result is 93.
- The signed interpretation of the output byte is 93.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01011101 (93 unsigned)
Bitwise arithmetic · Problem 0031
Calculate 13 − 4 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001101 and B=00000100.
- The unsigned values are A=13 and B=4.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000100 → 11111011.
- Add one to the inverted byte: 11111011 + 1 → 11111100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001101 + 11111100.
- Keep only the lowest eight bits: 00001001.
- Normal integers give 13−4=9.
- After modulo 256, the result is 9.
- 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: 00001001 (9 unsigned)
Bitwise arithmetic · Problem 0032
Calculate 13 − 239 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00001101 and B=11101111.
- The unsigned values are A=13 and B=239.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101111 → 00010000.
- Add one to the inverted byte: 00010000 + 1 → 00010001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00001101 + 00010001.
- Keep only the lowest eight bits: 00011110.
- Normal integers give 13−239=-226.
- After modulo 256, the result is 30.
- 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: 00011110 (30 unsigned)