Fully solved problem book
Eight-bit subtraction
Set 9 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 0257
Calculate 157 − 178 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10011101 and B=10110010.
- The unsigned values are A=157 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: 10011101 + 01001110.
- Keep only the lowest eight bits: 11101011.
- Normal integers give 157−178=-21.
- After modulo 256, the result is 235.
- 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: 11101011 (235 unsigned)
Bitwise arithmetic · Problem 0258
Calculate 158 − 44 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10011110 and B=00101100.
- The unsigned values are A=158 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: 10011110 + 11010100.
- Keep only the lowest eight bits: 01110010.
- Normal integers give 158−44=114.
- After modulo 256, the result is 114.
- The signed interpretation of the output byte is 114.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01110010 (114 unsigned)
Bitwise arithmetic · Problem 0259
Calculate 158 − 235 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10011110 and B=11101011.
- The unsigned values are A=158 and B=235.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101011 → 00010100.
- Add one to the inverted byte: 00010100 + 1 → 00010101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10011110 + 00010101.
- Keep only the lowest eight bits: 10110011.
- Normal integers give 158−235=-77.
- After modulo 256, the result is 179.
- The signed interpretation of the output byte is -77.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110011 (179 unsigned)
Bitwise arithmetic · Problem 0260
Calculate 159 − 89 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10011111 and B=01011001.
- The unsigned values are A=159 and B=89.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01011001 → 10100110.
- Add one to the inverted byte: 10100110 + 1 → 10100111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10011111 + 10100111.
- Keep only the lowest eight bits: 01000110.
- Normal integers give 159−89=70.
- After modulo 256, the result is 70.
- 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: 01000110 (70 unsigned)
Bitwise arithmetic · Problem 0261
Calculate 159 − 126 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10011111 and B=01111110.
- The unsigned values are A=159 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: 10011111 + 10000010.
- Keep only the lowest eight bits: 00100001.
- Normal integers give 159−126=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 0262
Calculate 160 − 175 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100000 and B=10101111.
- The unsigned values are A=160 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: 10100000 + 01010001.
- Keep only the lowest eight bits: 11110001.
- Normal integers give 160−175=-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 0263
Calculate 162 − 30 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100010 and B=00011110.
- The unsigned values are A=162 and B=30.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00011110 → 11100001.
- Add one to the inverted byte: 11100001 + 1 → 11100010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100010 + 11100010.
- Keep only the lowest eight bits: 10000100.
- Normal integers give 162−30=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 0264
Calculate 162 − 152 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100010 and B=10011000.
- The unsigned values are A=162 and B=152.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011000 → 01100111.
- Add one to the inverted byte: 01100111 + 1 → 01101000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100010 + 01101000.
- Keep only the lowest eight bits: 00001010.
- Normal integers give 162−152=10.
- After modulo 256, the result is 10.
- The signed interpretation of the output byte is 10.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00001010 (10 unsigned)
Bitwise arithmetic · Problem 0265
Calculate 162 − 178 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100010 and B=10110010.
- The unsigned values are A=162 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: 10100010 + 01001110.
- Keep only the lowest eight bits: 11110000.
- Normal integers give 162−178=-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 0266
Calculate 163 − 83 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=01010011.
- The unsigned values are A=163 and B=83.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010011 → 10101100.
- Add one to the inverted byte: 10101100 + 1 → 10101101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100011 + 10101101.
- Keep only the lowest eight bits: 01010000.
- Normal integers give 163−83=80.
- After modulo 256, the result is 80.
- The signed interpretation of the output byte is 80.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01010000 (80 unsigned)
Bitwise arithmetic · Problem 0267
Calculate 163 − 134 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=10000110.
- The unsigned values are A=163 and B=134.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10000110 → 01111001.
- Add one to the inverted byte: 01111001 + 1 → 01111010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100011 + 01111010.
- Keep only the lowest eight bits: 00011101.
- Normal integers give 163−134=29.
- After modulo 256, the result is 29.
- The signed interpretation of the output byte is 29.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00011101 (29 unsigned)
Bitwise arithmetic · Problem 0268
Calculate 163 − 141 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=10001101.
- The unsigned values are A=163 and B=141.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10001101 → 01110010.
- Add one to the inverted byte: 01110010 + 1 → 01110011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100011 + 01110011.
- Keep only the lowest eight bits: 00010110.
- Normal integers give 163−141=22.
- After modulo 256, the result is 22.
- The signed interpretation of the output byte is 22.
- 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 0269
Calculate 163 − 158 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=10011110.
- The unsigned values are A=163 and B=158.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011110 → 01100001.
- Add one to the inverted byte: 01100001 + 1 → 01100010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100011 + 01100010.
- Keep only the lowest eight bits: 00000101.
- Normal integers give 163−158=5.
- After modulo 256, the result is 5.
- The signed interpretation of the output byte is 5.
- 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 0270
Calculate 163 − 169 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=10101001.
- The unsigned values are A=163 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: 10100011 + 01010111.
- Keep only the lowest eight bits: 11111010.
- Normal integers give 163−169=-6.
- After modulo 256, the result is 250.
- 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: 11111010 (250 unsigned)
Bitwise arithmetic · Problem 0271
Calculate 163 − 178 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100011 and B=10110010.
- The unsigned values are A=163 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: 10100011 + 01001110.
- Keep only the lowest eight bits: 11110001.
- Normal integers give 163−178=-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 0272
Calculate 164 − 148 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100100 and B=10010100.
- The unsigned values are A=164 and B=148.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10010100 → 01101011.
- Add one to the inverted byte: 01101011 + 1 → 01101100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100100 + 01101100.
- Keep only the lowest eight bits: 00010000.
- Normal integers give 164−148=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 0273
Calculate 164 − 164 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100100 and B=10100100.
- The unsigned values are A=164 and B=164.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10100100 → 01011011.
- Add one to the inverted byte: 01011011 + 1 → 01011100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100100 + 01011100.
- Keep only the lowest eight bits: 00000000.
- Normal integers give 164−164=0.
- After modulo 256, the result is 0.
- The signed interpretation of the output byte is 0.
- 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 0274
Calculate 164 − 197 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100100 and B=11000101.
- The unsigned values are A=164 and B=197.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11000101 → 00111010.
- Add one to the inverted byte: 00111010 + 1 → 00111011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100100 + 00111011.
- Keep only the lowest eight bits: 11011111.
- Normal integers give 164−197=-33.
- After modulo 256, the result is 223.
- 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: 11011111 (223 unsigned)
Bitwise arithmetic · Problem 0275
Calculate 164 − 210 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100100 and B=11010010.
- The unsigned values are A=164 and B=210.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11010010 → 00101101.
- Add one to the inverted byte: 00101101 + 1 → 00101110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100100 + 00101110.
- Keep only the lowest eight bits: 11010010.
- Normal integers give 164−210=-46.
- After modulo 256, the result is 210.
- The signed interpretation of the output byte is -46.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11010010 (210 unsigned)
Bitwise arithmetic · Problem 0276
Calculate 164 − 251 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100100 and B=11111011.
- The unsigned values are A=164 and B=251.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111011 → 00000100.
- Add one to the inverted byte: 00000100 + 1 → 00000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100100 + 00000101.
- Keep only the lowest eight bits: 10101001.
- Normal integers give 164−251=-87.
- After modulo 256, the result is 169.
- The signed interpretation of the output byte is -87.
- 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 0277
Calculate 165 − 25 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100101 and B=00011001.
- The unsigned values are A=165 and B=25.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00011001 → 11100110.
- Add one to the inverted byte: 11100110 + 1 → 11100111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100101 + 11100111.
- Keep only the lowest eight bits: 10001100.
- Normal integers give 165−25=140.
- After modulo 256, the result is 140.
- The signed interpretation of the output byte is -116.
- 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 0278
Calculate 165 − 162 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100101 and B=10100010.
- The unsigned values are A=165 and B=162.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10100010 → 01011101.
- Add one to the inverted byte: 01011101 + 1 → 01011110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100101 + 01011110.
- Keep only the lowest eight bits: 00000011.
- Normal integers give 165−162=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 0279
Calculate 167 − 150 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100111 and B=10010110.
- The unsigned values are A=167 and B=150.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10010110 → 01101001.
- Add one to the inverted byte: 01101001 + 1 → 01101010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100111 + 01101010.
- Keep only the lowest eight bits: 00010001.
- Normal integers give 167−150=17.
- After modulo 256, the result is 17.
- The signed interpretation of the output byte is 17.
- 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 0280
Calculate 167 − 166 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10100111 and B=10100110.
- The unsigned values are A=167 and B=166.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10100110 → 01011001.
- Add one to the inverted byte: 01011001 + 1 → 01011010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10100111 + 01011010.
- Keep only the lowest eight bits: 00000001.
- Normal integers give 167−166=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 0281
Calculate 168 − 64 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101000 and B=01000000.
- The unsigned values are A=168 and B=64.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01000000 → 10111111.
- Add one to the inverted byte: 10111111 + 1 → 11000000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10101000 + 11000000.
- Keep only the lowest eight bits: 01101000.
- Normal integers give 168−64=104.
- After modulo 256, the result is 104.
- The signed interpretation of the output byte is 104.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01101000 (104 unsigned)
Bitwise arithmetic · Problem 0282
Calculate 169 − 48 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101001 and B=00110000.
- The unsigned values are A=169 and B=48.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00110000 → 11001111.
- Add one to the inverted byte: 11001111 + 1 → 11010000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10101001 + 11010000.
- Keep only the lowest eight bits: 01111001.
- Normal integers give 169−48=121.
- After modulo 256, the result is 121.
- The signed interpretation of the output byte is 121.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01111001 (121 unsigned)
Bitwise arithmetic · Problem 0283
Calculate 169 − 94 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101001 and B=01011110.
- The unsigned values are A=169 and B=94.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01011110 → 10100001.
- Add one to the inverted byte: 10100001 + 1 → 10100010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10101001 + 10100010.
- Keep only the lowest eight bits: 01001011.
- Normal integers give 169−94=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 0284
Calculate 170 − 36 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101010 and B=00100100.
- The unsigned values are A=170 and B=36.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100100 → 11011011.
- Add one to the inverted byte: 11011011 + 1 → 11011100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10101010 + 11011100.
- Keep only the lowest eight bits: 10000110.
- Normal integers give 170−36=134.
- After modulo 256, the result is 134.
- The signed interpretation of the output byte is -122.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10000110 (134 unsigned)
Bitwise arithmetic · Problem 0285
Calculate 170 − 76 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101010 and B=01001100.
- The unsigned values are A=170 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: 10101010 + 10110100.
- Keep only the lowest eight bits: 01011110.
- Normal integers give 170−76=94.
- After modulo 256, the result is 94.
- The signed interpretation of the output byte is 94.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01011110 (94 unsigned)
Bitwise arithmetic · Problem 0286
Calculate 170 − 202 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101010 and B=11001010.
- The unsigned values are A=170 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: 10101010 + 00110110.
- Keep only the lowest eight bits: 11100000.
- Normal integers give 170−202=-32.
- After modulo 256, the result is 224.
- The signed interpretation of the output byte is -32.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11100000 (224 unsigned)
Bitwise arithmetic · Problem 0287
Calculate 170 − 253 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101010 and B=11111101.
- The unsigned values are A=170 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: 10101010 + 00000011.
- Keep only the lowest eight bits: 10101101.
- Normal integers give 170−253=-83.
- After modulo 256, the result is 173.
- 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: 10101101 (173 unsigned)
Bitwise arithmetic · Problem 0288
Calculate 171 − 75 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=10101011 and B=01001011.
- The unsigned values are A=171 and B=75.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01001011 → 10110100.
- Add one to the inverted byte: 10110100 + 1 → 10110101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 10101011 + 10110101.
- Keep only the lowest eight bits: 01100000.
- Normal integers give 171−75=96.
- 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)