Data Representation and Multimedia: Question 8
Syllabus 1.1, 1.2, 1.3
An 8-bit register in a CPU represents signed integers.
(a) Represent the denary number -52 as an 8-bit value in one's complement. Show your method. [2]
(b) The register performs the subtraction 77 - 52 by adding the two's complement of 52 to the 8-bit binary value of 77. Find the two's complement of 52, show the bit-by-bit addition, and give the 8-bit result (discarding any carry out of the leftmost bit). [3]
(c) State one limitation of one's complement compared with two's complement for representing zero, and explain why this makes two's complement the preferred choice in most modern computer systems. [2]
Show worked solution Hide worked solution
Worked solution
Part (a): -52 in 8-bit one’s complement
Step 1 - write +52 in 8-bit binary. Using bit values 128, 64, 32, 16, 8, 4, 2, 1:
32 + 16 + 4 = 52
So +52 = 00110100.
Step 2 - invert every bit to form the one’s complement (change each 0 to 1 and each 1 to 0). Unlike two’s complement, one’s complement stops here - there is no “add 1” step.
00110100 -> 11001011
So -52 in 8-bit one’s complement is 11001011. [2 marks]: [1] for the correct binary of +52 (00110100), [1] for correctly inverting all 8 bits to reach 11001011, with no further “add 1” step.
(Check: inverting 11001011 back gives 00110100 = 52, confirming the magnitude is correct.)
Part (b): Subtracting via two’s complement addition
To subtract using two’s complement, first find the two’s complement of the number being subtracted (52), then add it to the other number (77) instead of subtracting directly.
Two’s complement of 52: invert 00110100 to get 11001011, then add 1:
11001011
+ 00000001
-----------
11001100
So the two’s complement of 52 (representing -52) is 11001100.
77 in binary: using bit values 128, 64, 32, 16, 8, 4, 2, 1: 64 + 8 + 4 + 1 = 77, so 77 = 01001101.
Adding 01001101 (77) and 11001100 (-52) column by column from the rightmost bit (bit 0), carrying into the next column whenever a column sums to 2 or more:
- Bit 0: 1 + 0 = 1, carry 0
- Bit 1: 0 + 0 = 0, carry 0
- Bit 2: 1 + 1 = 0, carry 1
- Bit 3: 1 + 1 + (carry 1) = 1, carry 1
- Bit 4: 0 + 0 + (carry 1) = 1, carry 0
- Bit 5: 0 + 0 = 0, carry 0
- Bit 6: 1 + 1 = 0, carry 1
- Bit 7: 0 + 1 + (carry 1) = 0, carry 1 (this final carry is discarded, since the register is only 8 bits wide)
0 1 0 0 1 1 0 1
+ 1 1 0 0 1 1 0 0
-----------------
0 0 0 1 1 0 0 1
So the 8-bit result is 00011001. [3 marks]: [1] for correctly finding the two’s complement of 52 (11001100), [1] for bit-by-bit addition working that correctly propagates carries, [1] for the correct 8-bit result 00011001 with the final carry discarded.
(Check: 00011001 = 16 + 8 + 1 = 25 in denary, and 77 - 52 = 25, confirming the result is correct. This also illustrates that adding two operands of opposite sign, as here, cannot itself cause overflow.)
Part (c): One’s complement’s limitation with zero
Limitation: One’s complement has two different bit patterns that both represent zero: 00000000 (positive zero, “+0”) and 11111111 (negative zero, “-0”, since inverting 00000000 gives 11111111).
Two’s complement, by contrast, has only one representation of zero, 00000000; inverting it and adding 1 simply gives 00000000 back again, not a separate “-0” pattern.
This matters because a system using one’s complement must treat two different bit patterns as equal to zero, which wastes an available code and complicates circuits that need to test for zero or perform addition and subtraction (a one’s complement adder needs an extra “end-around carry” step to work correctly). Two’s complement avoids all of this, which is why it is the representation used for signed integers in almost all modern computer systems.
[2 marks]: [1] for correctly identifying the dual representation of zero in one’s complement (00000000 and 11111111), [1] for linking this to why two’s complement (a single, unambiguous zero) is preferred in practice.
Final answers
- (a) -52 =
11001011(one’s complement) - (b)
01001101 + 11001100 = 00011001(denary 25, correctly giving 77 - 52) - (c) One’s complement has two representations of zero (
00000000and11111111); two’s complement has only one, which is why it is preferred