Subjects computer arithmetic

2S Complement Subtraction

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

2S Complement Subtraction


1. **Stating the problem:** We need to perform the subtraction $-27 - 19$ using 2's complement representation. 2. **Formula and rules:** In 2's complement, subtraction $A - B$ is done by adding $A$ to the 2's complement of $B$. 3. **Step 1: Convert numbers to binary:** - $27$ in binary (8-bit) is $00011011$. - $19$ in binary (8-bit) is $00010011$. 4. **Step 2: Represent $-27$ in 2's complement:** - Take binary of $27$: $00011011$. - Invert bits: $11100100$. - Add 1: $11100101$ (this is $-27$ in 2's complement). 5. **Step 3: Represent $19$ in 2's complement:** - Since we subtract $19$, we find 2's complement of $19$: - Invert bits of $00010011$: $11101100$. - Add 1: $11101101$ (this is $-19$ in 2's complement). 6. **Step 4: Perform addition $-27 + (-19)$:** $$11100101 + 11101101 = 110100010$$ - Since we are using 8 bits, discard the 9th bit (carry out), result is $10100010$. 7. **Step 5: Interpret the result:** - The result $10100010$ is negative (most significant bit is 1). - To find its magnitude, find 2's complement: - Invert bits: $01011101$. - Add 1: $01011110$ which is $94$ in decimal. 8. **Final answer:** $$-27 - 19 = -46$$ **Note:** The binary addition gave $-46$ as expected since $-27 - 19 = -46$. This shows how 2's complement subtraction works by converting subtraction into addition of the complement.