Fully solved problem book
Eight-bit subtraction
Set 3 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 0065
Calculate 34 − 225 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100010 and B=11100001.
- The unsigned values are A=34 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: 00100010 + 00011111.
- Keep only the lowest eight bits: 01000001.
- Normal integers give 34−225=-191.
- After modulo 256, the result is 65.
- The signed interpretation of the output byte is 65.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01000001 (65 unsigned)
Bitwise arithmetic · Problem 0066
Calculate 35 − 212 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100011 and B=11010100.
- The unsigned values are A=35 and B=212.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11010100 → 00101011.
- Add one to the inverted byte: 00101011 + 1 → 00101100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100011 + 00101100.
- Keep only the lowest eight bits: 01001111.
- Normal integers give 35−212=-177.
- After modulo 256, the result is 79.
- The signed interpretation of the output byte is 79.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01001111 (79 unsigned)
Bitwise arithmetic · Problem 0067
Calculate 36 − 13 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100100 and B=00001101.
- The unsigned values are A=36 and B=13.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001101 → 11110010.
- Add one to the inverted byte: 11110010 + 1 → 11110011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100100 + 11110011.
- Keep only the lowest eight bits: 00010111.
- Normal integers give 36−13=23.
- After modulo 256, the result is 23.
- The signed interpretation of the output byte is 23.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00010111 (23 unsigned)
Bitwise arithmetic · Problem 0068
Calculate 36 − 35 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100100 and B=00100011.
- The unsigned values are A=36 and B=35.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100011 → 11011100.
- Add one to the inverted byte: 11011100 + 1 → 11011101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100100 + 11011101.
- Keep only the lowest eight bits: 00000001.
- Normal integers give 36−35=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 0069
Calculate 36 − 229 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100100 and B=11100101.
- The unsigned values are A=36 and B=229.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100101 → 00011010.
- Add one to the inverted byte: 00011010 + 1 → 00011011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100100 + 00011011.
- Keep only the lowest eight bits: 00111111.
- Normal integers give 36−229=-193.
- After modulo 256, the result is 63.
- The signed interpretation of the output byte is 63.
- 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 0070
Calculate 37 − 13 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100101 and B=00001101.
- The unsigned values are A=37 and B=13.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001101 → 11110010.
- Add one to the inverted byte: 11110010 + 1 → 11110011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100101 + 11110011.
- Keep only the lowest eight bits: 00011000.
- Normal integers give 37−13=24.
- After modulo 256, the result is 24.
- The signed interpretation of the output byte is 24.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00011000 (24 unsigned)
Bitwise arithmetic · Problem 0071
Calculate 37 − 59 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100101 and B=00111011.
- The unsigned values are A=37 and B=59.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00111011 → 11000100.
- Add one to the inverted byte: 11000100 + 1 → 11000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100101 + 11000101.
- Keep only the lowest eight bits: 11101010.
- Normal integers give 37−59=-22.
- After modulo 256, the result is 234.
- 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: 11101010 (234 unsigned)
Bitwise arithmetic · Problem 0072
Calculate 37 − 230 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100101 and B=11100110.
- The unsigned values are A=37 and B=230.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11100110 → 00011001.
- Add one to the inverted byte: 00011001 + 1 → 00011010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100101 + 00011010.
- Keep only the lowest eight bits: 00111111.
- Normal integers give 37−230=-193.
- After modulo 256, the result is 63.
- The signed interpretation of the output byte is 63.
- 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 0073
Calculate 38 − 56 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100110 and B=00111000.
- The unsigned values are A=38 and B=56.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00111000 → 11000111.
- Add one to the inverted byte: 11000111 + 1 → 11001000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100110 + 11001000.
- Keep only the lowest eight bits: 11101110.
- Normal integers give 38−56=-18.
- After modulo 256, the result is 238.
- 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: 11101110 (238 unsigned)
Bitwise arithmetic · Problem 0074
Calculate 38 − 246 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100110 and B=11110110.
- The unsigned values are A=38 and B=246.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110110 → 00001001.
- Add one to the inverted byte: 00001001 + 1 → 00001010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100110 + 00001010.
- Keep only the lowest eight bits: 00110000.
- Normal integers give 38−246=-208.
- After modulo 256, the result is 48.
- The signed interpretation of the output byte is 48.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00110000 (48 unsigned)
Bitwise arithmetic · Problem 0075
Calculate 39 − 94 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100111 and B=01011110.
- The unsigned values are A=39 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: 00100111 + 10100010.
- Keep only the lowest eight bits: 11001001.
- Normal integers give 39−94=-55.
- After modulo 256, the result is 201.
- The signed interpretation of the output byte is -55.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11001001 (201 unsigned)
Bitwise arithmetic · Problem 0076
Calculate 39 − 222 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00100111 and B=11011110.
- The unsigned values are A=39 and B=222.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11011110 → 00100001.
- Add one to the inverted byte: 00100001 + 1 → 00100010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00100111 + 00100010.
- Keep only the lowest eight bits: 01001001.
- Normal integers give 39−222=-183.
- After modulo 256, the result is 73.
- The signed interpretation of the output byte is 73.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01001001 (73 unsigned)
Bitwise arithmetic · Problem 0077
Calculate 40 − 144 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101000 and B=10010000.
- The unsigned values are A=40 and B=144.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10010000 → 01101111.
- Add one to the inverted byte: 01101111 + 1 → 01110000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101000 + 01110000.
- Keep only the lowest eight bits: 10011000.
- Normal integers give 40−144=-104.
- After modulo 256, the result is 152.
- 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: 10011000 (152 unsigned)
Bitwise arithmetic · Problem 0078
Calculate 40 − 151 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101000 and B=10010111.
- The unsigned values are A=40 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: 00101000 + 01101001.
- Keep only the lowest eight bits: 10010001.
- Normal integers give 40−151=-111.
- After modulo 256, the result is 145.
- The signed interpretation of the output byte is -111.
- 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 0079
Calculate 40 − 217 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101000 and B=11011001.
- The unsigned values are A=40 and B=217.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11011001 → 00100110.
- Add one to the inverted byte: 00100110 + 1 → 00100111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101000 + 00100111.
- Keep only the lowest eight bits: 01001111.
- Normal integers give 40−217=-177.
- After modulo 256, the result is 79.
- The signed interpretation of the output byte is 79.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01001111 (79 unsigned)
Bitwise arithmetic · Problem 0080
Calculate 41 − 120 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101001 and B=01111000.
- The unsigned values are A=41 and B=120.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01111000 → 10000111.
- Add one to the inverted byte: 10000111 + 1 → 10001000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101001 + 10001000.
- Keep only the lowest eight bits: 10110001.
- Normal integers give 41−120=-79.
- After modulo 256, the result is 177.
- The signed interpretation of the output byte is -79.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10110001 (177 unsigned)
Bitwise arithmetic · Problem 0081
Calculate 44 − 28 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101100 and B=00011100.
- The unsigned values are A=44 and B=28.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00011100 → 11100011.
- Add one to the inverted byte: 11100011 + 1 → 11100100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101100 + 11100100.
- Keep only the lowest eight bits: 00010000.
- Normal integers give 44−28=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 0082
Calculate 44 − 59 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101100 and B=00111011.
- The unsigned values are A=44 and B=59.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00111011 → 11000100.
- Add one to the inverted byte: 11000100 + 1 → 11000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101100 + 11000101.
- Keep only the lowest eight bits: 11110001.
- Normal integers give 44−59=-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 0083
Calculate 47 − 85 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101111 and B=01010101.
- The unsigned values are A=47 and B=85.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010101 → 10101010.
- Add one to the inverted byte: 10101010 + 1 → 10101011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101111 + 10101011.
- Keep only the lowest eight bits: 11011010.
- Normal integers give 47−85=-38.
- After modulo 256, the result is 218.
- The signed interpretation of the output byte is -38.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 11011010 (218 unsigned)
Bitwise arithmetic · Problem 0084
Calculate 47 − 219 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00101111 and B=11011011.
- The unsigned values are A=47 and B=219.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11011011 → 00100100.
- Add one to the inverted byte: 00100100 + 1 → 00100101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00101111 + 00100101.
- Keep only the lowest eight bits: 01010100.
- Normal integers give 47−219=-172.
- After modulo 256, the result is 84.
- The signed interpretation of the output byte is 84.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 01010100 (84 unsigned)
Bitwise arithmetic · Problem 0085
Calculate 48 − 1 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110000 and B=00000001.
- The unsigned values are A=48 and B=1.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000001 → 11111110.
- Add one to the inverted byte: 11111110 + 1 → 11111111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110000 + 11111111.
- Keep only the lowest eight bits: 00101111.
- Normal integers give 48−1=47.
- After modulo 256, the result is 47.
- The signed interpretation of the output byte is 47.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 00101111 (47 unsigned)
Bitwise arithmetic · Problem 0086
Calculate 48 − 133 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110000 and B=10000101.
- The unsigned values are A=48 and B=133.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10000101 → 01111010.
- Add one to the inverted byte: 01111010 + 1 → 01111011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110000 + 01111011.
- Keep only the lowest eight bits: 10101011.
- Normal integers give 48−133=-85.
- After modulo 256, the result is 171.
- 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: 10101011 (171 unsigned)
Bitwise arithmetic · Problem 0087
Calculate 50 − 79 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110010 and B=01001111.
- The unsigned values are A=50 and B=79.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01001111 → 10110000.
- Add one to the inverted byte: 10110000 + 1 → 10110001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110010 + 10110001.
- Keep only the lowest eight bits: 11100011.
- Normal integers give 50−79=-29.
- After modulo 256, the result is 227.
- 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: 11100011 (227 unsigned)
Bitwise arithmetic · Problem 0088
Calculate 51 − 2 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110011 and B=00000010.
- The unsigned values are A=51 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: 00110011 + 11111110.
- Keep only the lowest eight bits: 00110001.
- Normal integers give 51−2=49.
- After modulo 256, the result is 49.
- 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: 00110001 (49 unsigned)
Bitwise arithmetic · Problem 0089
Calculate 51 − 123 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110011 and B=01111011.
- The unsigned values are A=51 and B=123.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01111011 → 10000100.
- Add one to the inverted byte: 10000100 + 1 → 10000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110011 + 10000101.
- Keep only the lowest eight bits: 10111000.
- Normal integers give 51−123=-72.
- After modulo 256, the result is 184.
- The signed interpretation of the output byte is -72.
- Discarding the ninth carry is valid for the fixed-width modular result; signed overflow is a separate question.
Final answer: 10111000 (184 unsigned)
Bitwise arithmetic · Problem 0090
Calculate 53 − 81 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110101 and B=01010001.
- The unsigned values are A=53 and B=81.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010001 → 10101110.
- Add one to the inverted byte: 10101110 + 1 → 10101111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110101 + 10101111.
- Keep only the lowest eight bits: 11100100.
- Normal integers give 53−81=-28.
- After modulo 256, the result is 228.
- 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: 11100100 (228 unsigned)
Bitwise arithmetic · Problem 0091
Calculate 54 − 59 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110110 and B=00111011.
- The unsigned values are A=54 and B=59.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00111011 → 11000100.
- Add one to the inverted byte: 11000100 + 1 → 11000101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110110 + 11000101.
- Keep only the lowest eight bits: 11111011.
- Normal integers give 54−59=-5.
- After modulo 256, the result is 251.
- 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: 11111011 (251 unsigned)
Bitwise arithmetic · Problem 0092
Calculate 55 − 6 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110111 and B=00000110.
- The unsigned values are A=55 and B=6.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000110 → 11111001.
- Add one to the inverted byte: 11111001 + 1 → 11111010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110111 + 11111010.
- Keep only the lowest eight bits: 00110001.
- Normal integers give 55−6=49.
- After modulo 256, the result is 49.
- 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: 00110001 (49 unsigned)
Bitwise arithmetic · Problem 0093
Calculate 55 − 233 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110111 and B=11101001.
- The unsigned values are A=55 and B=233.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101001 → 00010110.
- Add one to the inverted byte: 00010110 + 1 → 00010111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110111 + 00010111.
- Keep only the lowest eight bits: 01001110.
- Normal integers give 55−233=-178.
- 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 0094
Calculate 55 − 248 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00110111 and B=11111000.
- The unsigned values are A=55 and B=248.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11111000 → 00000111.
- Add one to the inverted byte: 00000111 + 1 → 00001000.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00110111 + 00001000.
- Keep only the lowest eight bits: 00111111.
- Normal integers give 55−248=-193.
- After modulo 256, the result is 63.
- The signed interpretation of the output byte is 63.
- 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 0095
Calculate 56 − 20 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00111000 and B=00010100.
- The unsigned values are A=56 and B=20.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00010100 → 11101011.
- Add one to the inverted byte: 11101011 + 1 → 11101100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00111000 + 11101100.
- Keep only the lowest eight bits: 00100100.
- Normal integers give 56−20=36.
- 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 0096
Calculate 56 − 172 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=00111000 and B=10101100.
- The unsigned values are A=56 and B=172.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10101100 → 01010011.
- Add one to the inverted byte: 01010011 + 1 → 01010100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 00111000 + 01010100.
- Keep only the lowest eight bits: 10001100.
- Normal integers give 56−172=-116.
- 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)