Assuming the computer is a 4-bit computer, what result is produced after subtraction of 3 from 5 using the 2's complement representation?
- (a)0101
- (b)10010
- (c)1101
- (d)11001
Correct — B, 10010. Work the subtraction the way a processor does. Five in four bits is 0101 and three is 0011. To subtract, the machine adds the two's complement of the second number: invert 0011 to get 1100, add one to get 1101, which is how minus three is held in four bits. Now add: 0101 + 1101 = 1 0010. That leading 1 is a carry out of the fourth bit position, and in two's complement arithmetic a carry out is discarded rather than kept — which leaves 0010, decimal two, the correct answer to five minus three. Here is where the paper's option list has to be described honestly rather than reasoned around: 0010 is not among the four choices. Option (b), 10010, is the same sum with the carry still attached, written as five bits on a question that has specified a four-bit computer. It is the only option that carries the correct working, and it is plainly what the examiner meant to reward, which is why it is marked as the answer. But a candidate who wrote 0010 in the margin was right about the machine, and should not conclude from this item that a four-bit result is ever five bits long.
- (a)0101 — This is five itself, unchanged. It is what you get by writing down the first operand and stopping, and it is the option that catches a candidate who converts to binary and forgets to subtract.
- (c)1101 — This is the two's complement of three — that is, minus three in four bits. It is the intermediate step of the calculation mistaken for its result, which is the most instructive wrong answer on the list.
- (d)11001 — Decimal twenty-five, reachable by no route through this problem. It exists to punish a candidate who is guessing at the shape of a five-bit string rather than doing the addition.
Two's complement is the standard way computers hold signed integers. The most significant bit carries the sign, non-negative numbers are written as usual, and a negative number is formed by inverting every bit of its magnitude and adding one. In four bits the representable range is minus eight to plus seven, and there is exactly one pattern for zero, which is why the scheme is preferred over sign-magnitude and over ones' complement. Its great practical advantage is that subtraction needs no separate circuit: to compute a minus b the machine adds a to the two's complement of b, and the same adder serves both operations. The carry that falls out of the top bit is discarded; what matters instead is overflow, which is signalled when the sign of the result is inconsistent with the signs of the operands.
The reliable method here is to run the three mechanical steps and not to look at the options until the end: write both numbers in the stated width, form the complement of the subtrahend, add. The examiner's own slip is worth naming, because it teaches the very rule the question is testing. A four-bit computer has four-bit registers; a result that runs to five bits is not a result the machine can hold, and the discarding of the carry is precisely how the arithmetic stays inside the register. Any option written as five bits on a four-bit question is therefore an intermediate quantity rather than a stored result. Note also that the discarded carry is not the same thing as overflow. Here the carry out is 1 and yet the answer is correct, because both operands and the result are inside the range minus eight to plus seven; overflow would be signalled by a sign that could not be right, as when two positive numbers add to a negative one.
- In four-bit two's complement the representable range is −8 to +7, with a single pattern, 0000, for zero.
- The two's complement of a number is formed by inverting all its bits and adding one; the two's complement of 0011 is 1101.
- Subtraction is performed as addition of the complement, so one adder circuit serves both operations.
- 0101 + 1101 = 1 0010; the carry out of the most significant bit is discarded, leaving the four-bit result 0010, which is decimal 2.
- A carry out of the top bit is not overflow. Overflow is detected from the signs of the operands and the result, not from the carry alone.
Do the three steps first and read the options afterwards. Here the correct four-bit result is 0010.
- Keeping the carry out of the most significant bit. In two's complement arithmetic it is discarded, and the result stays within the stated word length.
- Mistaking the complement of the second operand for the answer. 1101 is minus three, not the difference.
- Assuming that every printed option list contains the correct value. Here the true four-bit answer, 0010, is absent.
As a short arithmetic item asking for the result of an addition or subtraction in a stated word length, or as a conceptual item on what two's complement is and why it is used.
The memory of a computer is commonly expressed in terms of Kilobytes or Megabytes. A byte is made up of
- (a) eight binary digits
- (b) eight decimal digits
- (c) two binary digits
- (d) two decimal digits
Answer(a) eight binary digits
The same idea of a fixed word length, which is what decides this question. A machine that holds eight bits at a time cannot hold a nine-bit result, and a four-bit machine cannot hold a five-bit one — the surplus bit is dropped.
- practice — not a real PYQ
In four-bit two's complement representation, the bit pattern 1101 stands for which one of the following decimal values?
- (a)13
- (b)−3
- (c)−5
- (d)−13
Answer(b) −3 — invert 1101 to get 0010 and add one to get 0011, which is three, and the leading 1 marks it negative.
- practice — not a real PYQ
Using four bits and two's complement representation, the range of integers that can be represented is
- (a)0 to 15
- (b)−7 to +7
- (c)−8 to +7
- (d)−15 to +15
Answer(c) −8 to +7 — the asymmetry comes from there being a single pattern for zero, which frees one extra negative value.