Notes: Two’s Complement (Binary Numbers)
1. Introduction
● Binary numbers are normally assumed to be positive integers.
● To represent negative integers, we use two’s complement.
● Example: In an 8-bit register, column headings are:
−128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
Only the left-most bit (MSB) changes role:
● 0 → number is positive
● 1 → number is negative
Range of 8-bit Two’s Complement
● Minimum: 10000000 = −128
● Maximum: 01111111 = +127
● Range = −128 to +127
2. Identifying the Sign
● Left-most bit = sign bit
o 0 = positive number
o 1 = negative number
Example:
● 00110011 → +51
● 11001111 → −49
3. Writing Positive Numbers
● Positive numbers are written the same way as normal binary.
● Example 1: 19 → 00010011
● Example 2: 4 → 00000100
No change compared to ordinary binary.
4. Converting Positive Denary → Two’s Complement
Method:
1. Start from the −128 column (MSB must be 0).
2. Place 1s in columns that add up to the number.
Examples:
● 38 → 00100110
● 125 → 01111101
5. Converting Two’s Complement → Denary (Positive Numbers)
Method:
● Add values of all columns with 1.
Examples:
● 01101110 → 64 + 32 + 8 + 4 + 2 = 110
● 00111111 → 32 + 16 + 8 + 4 + 2 + 1 = 63
6. Writing Negative Numbers
For negatives, MSB = 1.
Examples:
● 10010011 → −128 + 16 + 2 + 1 = −109
● 11100100 → −128 + 64 + 32 + 4 = −28
● 11110101 → −128 + 64 + 32 + 16 + 4 + 1 = −11
7. Converting Negative Denary → Two’s Complement
Method 1 (Direct Method):
● Put a 1 in −128 column, then add other bits to make the number.
Example: −67
● −128 + 32 + 16 + 8 + 4 + 1 = −67
● Binary: 10111101
Method 2 (Inversion + 1):
1. Write the positive binary.
o +67 → 01000011
2. Invert digits (swap 1 ↔ 0).
o → 10111100
3. Add 1.
o → 10111101 (result = −67)
Both methods give same answer.
8. More Examples
● −79
o Method 1: −128 + 32 + 16 + 1 = 10110001
o Method 2:
▪ +79 → 01001111
▪ Invert → 10110000
▪ Add 1 → 10110001
● 4-bit Example
o 0110 = 6
o Invert → 1001
o Add 1 → 1010 → −6
● 12-bit Example
o 011010001100 = 1676
o Apply two’s complement → 100101100100 = −1676
9. Activities (Practice)
Convert denary → 8-bit two’s complement
● 39
● 66
● 88
● 102
● 111
● 125
● 77
● 20
● 56
Convert binary (two’s complement) → denary
● 01000010
● 00101100
● 01100101
● … (and others from text)
Convert negative denary → binary
● −18, −31, −47, −63, −88, −92, −100, −1, −16, −127
Convert negative binary → denary
(e.g., 11110101, 11011101, etc.)
10. Key Takeaways
● MSB = sign (0 = positive, 1 = negative).
● Positive numbers are unchanged from normal binary.
● Negative numbers can be found by:
1. Directly filling columns (Method 1).
2. Invert positive value & add 1 (Method 2).
● Range of 8-bit = −128 to +127.
● Two’s complement is the standard way computers store signed
integers