1's Complement, 2's Complement and Signed Binary Arithmetic
Computers store negative numbers with a sign bit and complements. In 2's complement a number is negated by inverting all bits and adding 1, and subtraction becomes addition.
Sign-magnitude uses the leftmost bit as the sign (0 positive, 1 negative) and the rest as the magnitude. 1's complement of a number inverts every bit. 2's complement is the 1's complement plus 1. In an n-bit 2's complement system the range is -2^(n-1) to 2^(n-1) - 1, so 8 bits cover -128 to 127. There is only one zero, which is why 2's complement is used almost everywhere.
To subtract A - B in 2's complement, add A to the 2's complement of B using the same number of bits. If there is a carry out of the leftmost bit with a positive result, discard it. If the result's sign bit is 1, the answer is negative and is stored in 2's complement form; to read its magnitude, take the 2's complement again.
Overflow occurs when two numbers of the same sign are added and the result has the opposite sign (or does not fit in n bits). Adding numbers of different signs can never overflow. Binary multiplication works like decimal long multiplication: 110 x 10 = 1100, since multiplying by 10 in binary shifts left by one.
Key points
- 1's complement: invert all bits. 2's complement: invert and add 1.
- n-bit 2's complement range: -2^(n-1) to 2^(n-1) - 1.
- A - B = A + (2's complement of B).
- Overflow: same-sign operands give a result of the opposite sign.
- The leftmost bit is the sign bit.
Worked example
Compute 7 - 5 with 4 bits. 5 = 0101, its 2's complement = 1010 + 1 = 1011. 0111 + 1011 = 1 0010. Drop the carry: 0010 = 2. Correct.
Common questions
How do you find the 2's complement of a binary number?
Invert every bit and add 1.
What is the range of an 8-bit 2's complement number?
-128 to +127.
Practice questions on this topic
Try these, then open the app to check your answers with explanations.
- Binary subtraction of 100101 − 011110 is ?
- A. 000111
- B. 111000
- C. 010101
- D. 101010
- Which of the following is the binary subtraction output of 0011010- 001100?
- A. 0101000
- B. 0001110
- C. 0010010
- D. 1000011
- Perform binary subtraction on: 101111 − 010101 = ?
- A. 100100
- B. 010101
- C. 011010
- D. 011001
- The output of NOT gate is complement of its input.
- A. True
- B. False
- What is the First complement for the binary number 011001.
- A. 000111
- B. 100110
- C. 100111
- D. 110001
- What is the second complement for the binary number 011001.
- A. 000111
- B. 100110
- C. 100111
- D. 110001
Related topics
- Number System Conversion: Binary, Octal, Decimal and Hexadecimal
- Boolean Algebra Laws, De Morgan Theorems and Simplification
- Logic Gates: AND, OR, NOT, NAND, NOR, XOR and Universal Gates
- Karnaugh Map (K-Map) Simplification Step by Step
- SOP and POS: Minterms, Maxterms and Canonical Forms
- Half Adder, Full Adder, Multiplexer and Decoder Explained
- All topics: Digital Logic
BASMAGLY is an independent student project, not an official Delta University site. Check lectures and your instructor for the final word.