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 →
- Start with A=01001111 and B=00100110.
- The unsigned values are A=79 and B=38.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100110 → 11011001.
- Add one to the inverted byte: 11011001 + 1 → 11011010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01001111 + 11011010.
- Keep only the lowest eight bits: 00101001.
- Normal integers give 79−38=41.
- After modulo 256, the result is 41.
- The signed interpretation of the output byte is 41.
- 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 →
- Start with A=01001111 and B=00101100.
- The unsigned values are A=79 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: 01001111 + 11010100.
- Keep only the lowest eight bits: 00100011.
- Normal integers give 79−44=35.
- After modulo 256, the result is 35.
- The signed interpretation of the output byte is 35.
- 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 →
- Start with A=01001111 and B=00110110.
- The unsigned values are A=79 and B=54.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00110110 → 11001001.
- Add one to the inverted byte: 11001001 + 1 → 11001010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01001111 + 11001010.
- Keep only the lowest eight bits: 00011001.
- Normal integers give 79−54=25.
- After modulo 256, the result is 25.
- The signed interpretation of the output byte is 25.
- 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 →
- Start with A=01001111 and B=10001000.
- The unsigned values are A=79 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: 01001111 + 01111000.
- Keep only the lowest eight bits: 11000111.
- Normal integers give 79−136=-57.
- After modulo 256, the result is 199.
- The signed interpretation of the output byte is -57.
- 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 →
- Start with A=01001111 and B=11001100.
- The unsigned values are A=79 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: 01001111 + 00110100.
- Keep only the lowest eight bits: 10000011.
- Normal integers give 79−204=-125.
- After modulo 256, the result is 131.
- The signed interpretation of the output byte is -125.
- 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 →
- Start with A=01001111 and B=11110111.
- The unsigned values are A=79 and B=247.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110111 → 00001000.
- Add one to the inverted byte: 00001000 + 1 → 00001001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01001111 + 00001001.
- Keep only the lowest eight bits: 01011000.
- Normal integers give 79−247=-168.
- After modulo 256, the result is 88.
- The signed interpretation of the output byte is 88.
- 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 →
- Start with A=01010001 and B=11100110.
- The unsigned values are A=81 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: 01010001 + 00011010.
- Keep only the lowest eight bits: 01101011.
- Normal integers give 81−230=-149.
- After modulo 256, the result is 107.
- 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: 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 →
- Start with A=01010010 and B=10010100.
- The unsigned values are A=82 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: 01010010 + 01101100.
- Keep only the lowest eight bits: 10111110.
- Normal integers give 82−148=-66.
- After modulo 256, the result is 190.
- The signed interpretation of the output byte is -66.
- 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 →
- Start with A=01010010 and B=10111101.
- The unsigned values are A=82 and B=189.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10111101 → 01000010.
- Add one to the inverted byte: 01000010 + 1 → 01000011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010010 + 01000011.
- Keep only the lowest eight bits: 10010101.
- Normal integers give 82−189=-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 0138
Calculate 82 − 242 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010010 and B=11110010.
- The unsigned values are A=82 and B=242.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11110010 → 00001101.
- Add one to the inverted byte: 00001101 + 1 → 00001110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010010 + 00001110.
- Keep only the lowest eight bits: 01100000.
- Normal integers give 82−242=-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 0139
Calculate 83 − 191 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010011 and B=10111111.
- The unsigned values are A=83 and B=191.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10111111 → 01000000.
- Add one to the inverted byte: 01000000 + 1 → 01000001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010011 + 01000001.
- Keep only the lowest eight bits: 10010100.
- Normal integers give 83−191=-108.
- After modulo 256, the result is 148.
- The signed interpretation of the output byte is -108.
- 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 →
- Start with A=01010011 and B=11011011.
- The unsigned values are A=83 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: 01010011 + 00100101.
- Keep only the lowest eight bits: 01111000.
- Normal integers give 83−219=-136.
- After modulo 256, the result is 120.
- The signed interpretation of the output byte is 120.
- 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 →
- Start with A=01010100 and B=01111001.
- The unsigned values are A=84 and B=121.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01111001 → 10000110.
- Add one to the inverted byte: 10000110 + 1 → 10000111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010100 + 10000111.
- Keep only the lowest eight bits: 11011011.
- Normal integers give 84−121=-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 0142
Calculate 85 − 9 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010101 and B=00001001.
- The unsigned values are A=85 and B=9.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00001001 → 11110110.
- Add one to the inverted byte: 11110110 + 1 → 11110111.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010101 + 11110111.
- Keep only the lowest eight bits: 01001100.
- Normal integers give 85−9=76.
- 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 0143
Calculate 86 − 3 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010110 and B=00000011.
- The unsigned values are A=86 and B=3.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00000011 → 11111100.
- Add one to the inverted byte: 11111100 + 1 → 11111101.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010110 + 11111101.
- Keep only the lowest eight bits: 01010011.
- Normal integers give 86−3=83.
- 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 0144
Calculate 86 − 23 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010110 and B=00010111.
- The unsigned values are A=86 and B=23.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00010111 → 11101000.
- Add one to the inverted byte: 11101000 + 1 → 11101001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010110 + 11101001.
- Keep only the lowest eight bits: 00111111.
- Normal integers give 86−23=63.
- 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 0145
Calculate 86 − 111 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010110 and B=01101111.
- The unsigned values are A=86 and B=111.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01101111 → 10010000.
- Add one to the inverted byte: 10010000 + 1 → 10010001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010110 + 10010001.
- Keep only the lowest eight bits: 11100111.
- Normal integers give 86−111=-25.
- After modulo 256, the result is 231.
- The signed interpretation of the output byte is -25.
- 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 →
- Start with A=01010110 and B=11011110.
- The unsigned values are A=86 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: 01010110 + 00100010.
- Keep only the lowest eight bits: 01111000.
- Normal integers give 86−222=-136.
- After modulo 256, the result is 120.
- The signed interpretation of the output byte is 120.
- 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 →
- Start with A=01010110 and B=11100101.
- The unsigned values are A=86 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: 01010110 + 00011011.
- Keep only the lowest eight bits: 01110001.
- Normal integers give 86−229=-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 0148
Calculate 86 − 237 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01010110 and B=11101101.
- The unsigned values are A=86 and B=237.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11101101 → 00010010.
- Add one to the inverted byte: 00010010 + 1 → 00010011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01010110 + 00010011.
- Keep only the lowest eight bits: 01101001.
- Normal integers give 86−237=-151.
- After modulo 256, the result is 105.
- The signed interpretation of the output byte is 105.
- 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 →
- Start with A=01010111 and B=10101001.
- The unsigned values are A=87 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: 01010111 + 01010111.
- Keep only the lowest eight bits: 10101110.
- Normal integers give 87−169=-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 0150
Calculate 88 − 39 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011000 and B=00100111.
- The unsigned values are A=88 and B=39.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 00100111 → 11011000.
- Add one to the inverted byte: 11011000 + 1 → 11011001.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011000 + 11011001.
- Keep only the lowest eight bits: 00110001.
- Normal integers give 88−39=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 0151
Calculate 89 − 64 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011001 and B=01000000.
- The unsigned values are A=89 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: 01011001 + 11000000.
- Keep only the lowest eight bits: 00011001.
- Normal integers give 89−64=25.
- After modulo 256, the result is 25.
- The signed interpretation of the output byte is 25.
- 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 →
- Start with A=01011001 and B=10011010.
- The unsigned values are A=89 and B=154.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10011010 → 01100101.
- Add one to the inverted byte: 01100101 + 1 → 01100110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011001 + 01100110.
- Keep only the lowest eight bits: 10111111.
- Normal integers give 89−154=-65.
- After modulo 256, the result is 191.
- 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: 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 →
- Start with A=01011001 and B=10110101.
- The unsigned values are A=89 and B=181.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10110101 → 01001010.
- Add one to the inverted byte: 01001010 + 1 → 01001011.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011001 + 01001011.
- Keep only the lowest eight bits: 10100100.
- Normal integers give 89−181=-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 0154
Calculate 90 − 90 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011010 and B=01011010.
- The unsigned values are A=90 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: 01011010 + 10100110.
- Keep only the lowest eight bits: 00000000.
- Normal integers give 90−90=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 0155
Calculate 90 − 206 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011010 and B=11001110.
- The unsigned values are A=90 and B=206.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 11001110 → 00110001.
- Add one to the inverted byte: 00110001 + 1 → 00110010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011010 + 00110010.
- Keep only the lowest eight bits: 10001100.
- Normal integers give 90−206=-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)
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 →
- Start with A=01011011 and B=00011001.
- The unsigned values are A=91 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: 01011011 + 11100111.
- Keep only the lowest eight bits: 01000010.
- Normal integers give 91−25=66.
- After modulo 256, the result is 66.
- The signed interpretation of the output byte is 66.
- 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 →
- Start with A=01011011 and B=01010110.
- The unsigned values are A=91 and B=86.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01010110 → 10101001.
- Add one to the inverted byte: 10101001 + 1 → 10101010.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011011 + 10101010.
- Keep only the lowest eight bits: 00000101.
- Normal integers give 91−86=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 0158
Calculate 91 − 132 in eight-bit modular arithmetic.
Try it on paper first. The worked answer is hidden below.
Reveal detailed solution →
- Start with A=01011011 and B=10000100.
- The unsigned values are A=91 and B=132.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 10000100 → 01111011.
- Add one to the inverted byte: 01111011 + 1 → 01111100.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011011 + 01111100.
- Keep only the lowest eight bits: 11010111.
- Normal integers give 91−132=-41.
- After modulo 256, the result is 215.
- The signed interpretation of the output byte is -41.
- 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 →
- Start with A=01011100 and B=00010100.
- The unsigned values are A=92 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: 01011100 + 11101100.
- Keep only the lowest eight bits: 01001000.
- Normal integers give 92−20=72.
- After modulo 256, the result is 72.
- 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: 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 →
- Start with A=01011101 and B=01110010.
- The unsigned values are A=93 and B=114.
- Rewrite subtraction as A + (NOT B) + 1.
- Invert every bit of B: 01110010 → 10001101.
- Add one to the inverted byte: 10001101 + 1 → 10001110.
- This new byte represents the modular additive inverse of B.
- Add A and modular −B: 01011101 + 10001110.
- Keep only the lowest eight bits: 11101011.
- Normal integers give 93−114=-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)