Information representation

Information representation

Negative numbers, binary arithmetic and overflow

Data Representation AS Level 30 min read

On this page
  1. What you need to be able to do
  2. Unsigned and signed integers
  3. One's complement
  4. Two's complement
  5. Binary addition
  6. Binary subtraction
  7. Overflow
  8. Mark-scheme focus
  9. Worked examples
  10. Summary
  11. Can I do this?
  12. Quiz

What you need to be able to do

Syllabus 1.1 Data representation
  • 1.1Represent negative integers in one's complement and two's complement, and convert both ways between denary and two's complement (8-bit, 12-bit …).
  • 1.1State the range of an n-bit unsigned or two's complement integer.
  • 1.1Perform binary addition and binary subtraction with positive and negative integers, showing the working.
  • 1.1Show understanding of how overflow can occur, and spot it in a calculation.

You need: binary place values and denary ↔ binary from Number bases, prefixes and BCD. Logical and arithmetic shifts are syllabus 4.3 and are taught in Chapter 4 (Bit manipulation).

Unsigned and signed integers

So far every pattern meant a positive number: an unsigned integer uses all n bits for size, 0 to \(2^n-1\). A computer has no minus sign to write, so to store negative numbers it must give some bit patterns a negative meaning. Such a number is a signed integer, and the left-hand bit, the most significant bit (MSB), becomes the sign bit: 0 for positive, 1 for negative. The syllabus uses two ways of doing this.

One's complement

One's complement: a negative number is made by flipping every bit (0 ↔ 1) of the positive number.
Flip every bit of +45 to get −45 in one's complement. The sign bit becomes 1.
1286432168421
+4500101101
−45 (one's)11010010

Denary → one's complement

Write the positive number in n bits, then flip every bit. −120: +120 = 0111 1000 → 1000 0111.

One's complement → denary

Sign bit 0: read it as normal. Sign bit 1: flip every bit back, read the size, put a minus sign in front.

Range (8 bits)

−127 to +127. There are two zeros: 0000 0000 (+0) and 1111 1111 (−0). That wasted pattern, and the awkward arithmetic, are why computers use two's complement instead.

June 2023 trap: for “the one's complement of −120” many candidates gave the two's complement (1000 1000), or worked out the two's complement first and flipped that (0111 0111). One's complement is just the flip of +120: 1000 0111.

Two's complement

Two's complement: the MSB has a negative place value. In 8 bits the column values are −128, 64, 32, 16, 8, 4, 2, 1, and the number is the sum of the columns that hold a 1.
1011 0101 = −128 + 32 + 16 + 4 + 1 = −75. The pink bit is worth −128.
−1286432168421
10110101

For 12 bits the MSB is worth −2048 (\(-2^{11}\)); for 16 bits, −32 768. In general the MSB of n bits is worth \(-2^{n-1}\).

Denary to two's complement

  1. If the number is positive: write it in binary with a 0 sign bit, padded to the number of bits asked for. Done.
  2. If it is negative: write the positive version in the full number of bits (e.g. +45 = 0010 1101).
  3. Flip every bit (one's complement): 1101 0010.
  4. Add 1: 1101 0010 + 1 = 1101 0011. Check: the sign bit is 1, as a negative must be.
Flip, then add 1. The carries show where the 1 ripples along.
1286432168421
Carries
Flipped +4511010010
add 1+00000001
−4511010011
A quick way to check (or to do it): copy the bits of the positive number from the right up to and including the first 1, then flip everything to the left of it. +44 = 0010 1100 → keep “100”, flip the rest → 1101 0100 = −44.

Two's complement to denary: two methods, same example (1001 1111)

Method A: give the MSB its negative value

  1. Write the place values with the MSB negative: −128, 64, 32, 16, 8, 4, 2, 1.
  2. Add the values that have a 1: −128 + 16 + 8 + 4 + 2 + 1.
  3. = −128 + 31 = −97.

Method B: undo it with flip and add 1

  1. The sign bit is 1, so the number is negative.
  2. Flip every bit: 0110 0000. Add 1: 0110 0001.
  3. Read that as a normal positive number: 64 + 32 + 1 = 97. Put the minus sign back: −97.

Both methods are in the mark scheme (November 2024): “Flip each bit then add 1 … convert the new binary number into denary” or “Most significant 1 bit is treated as the corresponding negative denary value … add the other positive corresponding denary values”.

Range

SmallestLargest8-bit example
Unsigned n bits0\(2^n-1\)0 to 255
One's complement n bits\(-(2^{n-1}-1)\)\(2^{n-1}-1\)−127 to 127
Two's complement n bits\(-2^{n-1}\)\(2^{n-1}-1\)−128 (1000 0000) to 127 (0111 1111)
The smallest 8-bit two's complement number is −128 = 1000 0000, not −127 (June 2023 report). Two's complement has only one zero, so it has room for one extra negative number. When asked for the smallest and largest binary numbers, write the bit patterns, not just −128 and 127.

1 Negative to 8-bit two's complement

Write −100 as an 8-bit two's complement integer.

Asked8-bit patternKnow+100 = 0110 0100Routeflip, add 1

  1. Flip: 1001 1011
  2. Add 1: 1001 1100

Check with Method A: −128 + 16 + 8 + 4 = −100 ✓

2 Negative to 12-bit

Write −196 as a 12-bit two's complement integer.

Asked12-bit patternKnow+196 = 0000 1100 0100Routeflip, add 1 across all 12 bits

  1. Flip: 1111 0011 1011
  2. Add 1: 1111 0011 1100

Pad the positive number to the full 12 bits before flipping, or the leading 1s are lost.

3 A 12-bit pattern to denary

1110 0110 0001 is a 12-bit two's complement integer. Find its denary value.

AskeddenaryKnowMSB worth −2048Routeadd the place values

  1. −2048 + 1024 + 512 + 64 + 32 + 1
  2. = −2048 + 1633 = −415

4 Positive in two's complement

Write +37 as an 8-bit two's complement integer.

Asked8-bit patternKnowpositiveRouteordinary binary, sign bit 0

  1. 37 = 32 + 4 + 1 = 0010 0101

Positive numbers look exactly the same as unsigned ones. Flip-and-add-1 is only for negatives.

5 The same pattern, two meanings

What is 1100 1000 as an unsigned integer and as a two's complement integer?

Askedtwo valuesKnowsame bitsRouteMSB +128 or −128

  1. Unsigned: 128 + 64 + 8 = 200
  2. Two's complement: −128 + 64 + 8 = −56

The two differ by exactly 256 (\(2^8\)). Treating a two's complement number as unsigned (answering 200) was the most common wrong answer in November 2022.

Binary addition

Add column by column from the right, exactly like denary addition, but you carry as soon as a column reaches 2.

In the columnTotalWriteCarry
0 + 000-
0 + 1 or 1 + 011-
1 + 12 = 10₂01
1 + 1 + carry 13 = 11₂11
74 + 23 = 97. The carry row is part of the working the scheme wants to see.
1286432168421
Carries1111
A01001010
B+00010111
Answer01100001
“Show your working” in binary addition means: the carry bits must be clearly visible (the June 2021 report), and the answer must be clearly labelled.

Try it yourself. Fill in every answer bit and every carry, right to left, like a dry run. Wrong bits turn pink and the caption tells you why; “New numbers” gives fresh ones (some overflow).

Binary addition workbench

108 + 83: the answer 1011 1111 has sign bit 1. As two's complement that is −65: an overflow (see below).
1286432168421
Carries1
A01101100
B+01010011
Answer10111111

Binary subtraction

The mark scheme accepts two methods. Both are worked below on the same sum, 100 − 59 (= 41).

Method A: A − B = A + (−B)

  1. Write both numbers in binary with the same number of bits.
  2. Make −B: flip every bit of B and add 1 (two's complement).
  3. Add A + (−B) column by column.
  4. Ignore the carry out of the left column: in two's complement it is discarded (the scheme writes it in brackets).
Two's complement of 59: flip, add 1.
+5900111011
flipped11000100
−5911000101
The (1) carried out of the left column is ignored: 0010 1001 = 41 ✓
1286432168421
Carries111
10001100100
−59+11000101
100 − 59100101001

Method B: subtract column by column, borrowing

  1. Work from the right. In each column take the bottom bit from the top bit.
  2. If the top is 0 and the bottom is 1, borrow from the next column to the left: that column loses 1, and this column becomes 10₂ = 2, so 2 − 1 = 1.
  3. A column that has lent and was 0 must itself borrow from further left (the borrow ripples, like 1000 − 1 in denary).
  4. Show the borrows: the scheme gives the working mark for visible borrowing.
A 1 in the top row marks a column that lent 1 to its right-hand neighbour. 0010 1001 = 32 + 8 + 1 = 41 ✓, the same as Method A.
1286432168421
Lent 111111
10001100100
59−00111011
100 − 5900101001
The wrong way round is the most reported mistake (June 2021, November 2021, June 2022). “Subtract 10 from 35” is 35 − 10: the number being taken away (10) is the one you make negative. And “perform the subtraction in binary” means in binary: converting to denary, subtracting and converting back earns no working marks (November 2022).

Try it yourself. The workbench below makes you do every step of Method A: flip the bits of B, add 1, then add.

Binary subtraction workbench (A − B)

90 − 45: −45 = 1101 0011 (flip 0010 1101, add 1). The final carry is ignored: 0010 1101 = 45.
1286432168421
Carries1111
9001011010
−45+11010011
90 − 45100101101

Overflow

Overflow: the result of a calculation is too large (or too small) to be represented in the number of bits available: larger than the maximum positive number, or smaller than the most negative number, the register can store.

Unsigned numbers

Overflow happens when there is a carry out of the left-hand column. 8 bits hold at most 255; 200 + 100 = 300 needs a ninth bit, so the register keeps only 300 − 256 = 44.

Two's complement numbers

Overflow happens when you add two numbers with the same sign and the answer has the other sign: positive + positive gives a “negative”, or negative + negative gives a “positive”. A carry out of the left column on its own is not overflow here - it is discarded.

Never overflows

Adding a positive to a negative (two's complement) can never overflow: the answer always lies between them.

What the processor does

The overflow is recorded in the status register (an overflow flag) so that software can detect the wrong answer. More in Chapter 4.

1 Unsigned overflow

Add 1100 1000 and 0110 0100 as unsigned 8-bit integers.

Askedresult + overflow?Know200 + 100 = 300 > 255Routecarry out of the MSB?

  1. Sum: 0010 1100 with a carry out of 1
  2. 300 needs 9 bits: overflow. The register holds 0010 1100 = 44.

2 Two's complement: positive + positive

Add 0101 0000 and 0011 0000 as 8-bit two's complement.

Askedresult + overflow?Know80 + 48 = 128 > 127Routecheck the sign bits

  1. Sum: 1000 0000, no carry out
  2. Two positives gave a negative pattern (−128): overflow.

No carry out, yet still overflow: in two's complement you judge by the sign bits.

3 Two's complement: carry out but no overflow

Add 1111 1100 (−4) and 0000 0110 (+6) as 8-bit two's complement.

Askedresult + overflow?Know−4 + 6 = 2Routedifferent signs: can't overflow

  1. Sum: (1) 0000 0010: discard the carry
  2. Answer 0000 0010 = 2 ✓, no overflow

4 Two's complement: negative + negative

Add 1000 0001 (−127) and 1111 1110 (−2) as 8-bit two's complement.

Askedresult + overflow?Know−127 − 2 = −129 < −128Routecheck the sign bits

  1. Sum: (1) 0111 1111
  2. Two negatives gave a positive (127): overflow.

Mark-scheme focus

“State what is meant by an overflow in binary addition” (1 mark)

9618/13/M/J/24 Q1Paper 1 · Theory fundamentalsPart (c)1 markFull size
(c) State what is meant by an overflow in binary addition. [1]
Credited
  • The answer is too long to be represented in the same number of bits as the binary numbers being added
  • The answer cannot be represented in the number of bits available // is larger than the maximum positive number (or smaller than the most negative number) that can be stored in the register
Not credited
  • “Bits going off the end” (the November 2021 report: not enough at this level)
  • “The number is too big” with no mention of the bits / register
Why

The idea that earns the mark is the fixed number of bits: the result needs more bits than the register has.

Also accepted

For 8-bit unsigned: “the result is greater than 255”. A 2-mark version (November 2025) also credits naming it: “An overflow error occurs”.

From: 9618/13/M/J/24 Q1(c)

“Explain how to convert 10011111 into denary” (3 marks)

9618/13/O/N/24 Q8Paper 1 · Theory fundamentalsPart (b)3 marksFull size
(b) Explain how to convert the two's complement integer 10011111 into denary. Give the denary value after conversion. [3]
Credited
  • Flip each bit then add 1 … B1 then convert the new binary number into denary (and make it negative) B1
  • or: the most significant 1 bit is treated as the corresponding negative denary value (−128) B1 … add the other positive denary values B1
  • Denary value: −97 B1
Not credited
  • Just the answer −97 (1 of 3)
  • Describing the method for unsigned binary (giving 159)
  • −97 without a method, or a method without saying the MSB is negative
Why

Two marks are for the method in words. Say what happens to the MSB, not just “add up the place values”.

From: 9618/13/O/N/24 Q8(b)

“Give the 8-bit one's complement representation of −120” (2 marks)

9618/12/M/J/23 Q4Paper 1 · Theory fundamentalsPart (b)2 marksFull size
(b) Give the 8-bit one's complement representation of the denary number −120. Show your working. [2]
Credited
  • Working: +120 = 0111 1000 B1
  • Answer: 1000 0111 B1
Not credited
  • 1000 1000 (that is the two's complement)
  • 0111 0111 (one's complement of the two's complement)
Why

One's complement stops after the flip. The report says many candidates added 1 out of habit.

From: 9618/12/M/J/23 Q4(b)

Smallest and largest values (3 marks)

9618/13/M/J/23 Q7Paper 1 · Theory fundamentalsPart (a)3 marksFull size
(a) Draw one line from each description to its matching denary value: the smallest integer that can be represented in 8-bit two's complement; the largest integer that can be represented in 8-bit two's complement; the largest unsigned integer that can be represented in 8 bits. Values: 127, −255, −128, −256, 256, 128, 255, −127. [3]
Credited
  • Smallest 8-bit two's complement → −128 B1
  • Largest 8-bit two's complement → 127 B1
  • Largest unsigned 8-bit → 255 B1
Not credited
  • −127 for the smallest (that is one's complement's limit)
  • 256 for the largest unsigned (that is how many values)
Why

The extra negative value exists because two's complement has a single zero.

From: 9618/13/M/J/23 Q7(a)

  • Two's complement ↔ denary: almost every paper, 1 mark each (8-bit or 12-bit). Missing minus signs and treating the number as unsigned are the usual losses.
  • Addition: 1-3 marks. With 3 marks: working (carries) + answer + overflow indicated (e.g. a three-number sum).
  • Subtraction: 2-3 marks: converting the numbers, the method (two's complement and add, or borrowing), the answer.
  • Overflow: “state / describe” for 1-2 marks, in about one paper in three.

Worked examples

Example 1 · Two's complement to denary, then a subtraction (Paper 1, 3 marks) ★ Easy
9618/11/O/N/22 Q1Paper 1 · Theory fundamentalsParts (a)(iii) and (b)3 marksFull size
(a)(iii) Convert the 8-bit two's complement binary integer 11100111 into denary. [1] (b) Perform the following binary subtraction. Show your working. 10110011 − 01110101 [2]
1 Read it with me what is actually happening?

(a)(iii) is a negative two's complement number (MSB 1). (b) subtracts the bottom number from the top one: you choose the method, but the working must show.

  • 8-bit two's complementMSB = −128
  • show your workingborrows, or the two's complement + carries
2 What is it asking for? the target, part by part
  • (a)(iii)denary value1
  • (b)binary answer2: working + answer
3 What do we know? everything the question gives us
  • 1110 0111(a)
  • 1011 0011 − 0111 0101(b)
  • (b) as unsigned: 179 − 117
4 Plan the route work backwards from what we want
FindKey ideaAlready have itWork out firstTrap
  • (a)(iii)denary
    • Method A−128 + 64 + 32 + 4 + 2 + 1
  • (b)difference
    • Chooseborrowing, or add −0111 0101
    • Trapdoing it in denary only
Is 1110 0111 negative?

Yes: the MSB is 1. The answer must have a minus sign.

What should (b) come to?

179 − 117 = 62, so expect 0011 1110.

5 Now solve it have a go on paper first, then open the worked solution
  1. (a)(iii) −128 + 64 + 32 + 4 + 2 + 1 = −25 B1
  2. (b) borrowing column by column (the 1s mark columns that lent):
  3. Answer 0011 1110 B1 B1 (working + answer)
1286432168421
Lent 111111
10110011
−01110101
Answer00111110

Method A also scores: −0111 0101 = 1000 1011, then 1011 0011 + 1000 1011 = (1) 0011 1110.

6 Check it does the answer make sense?

62 in denary ✓. The report: “when the question asks for the subtraction to be completed in binary no working marks will be awarded for converting to denary”.

Example 2 · A 12-bit number with a method, then addition and the error it can cause (Paper 1, 5 marks) ★★ Medium
9618/11/O/N/25 Q1Paper 1 · Theory fundamentalsParts (a)(iii) and (b)5 marksFull size
(a)(iii) Convert the 12-bit two's complement binary integer 111110111100 into denary. Show your working. [2] (b)(i) The following binary addition is performed using 8-bit registers: 10110011 + 01111000. Complete the calculation using binary addition. [1] (ii) Name and describe the error that can occur when binary addition is performed. [2]
1 Read it with me what is actually happening?

A 12-bit two's complement number: the MSB is worth −2048. Then an 8-bit addition whose true answer needs 9 bits, which leads into (b)(ii).

  • 12-bitMSB worth −2048
  • 8-bit registersonly 8 bits are kept
  • name and describe1 mark for the name, 1 for what it means
2 What is it asking for? the target, part by part
  • (a)(iii)denary2
  • (b)(i)8-bit sum1
  • (b)(ii)the error2
3 What do we know? everything the question gives us
  • 1111 1011 1100(a)
  • 1011 0011 + 0111 1000(b)
4 Plan the route work backwards from what we want
FindKey ideaAlready have itWork out firstTrap
  • (a)(iii)denary
    • Flip, add 10000 0100 0100 = 68 → −68
    • or−2048 + 1024 + 512 + …
  • (b)sum
    • Traplosing the carry out
    • (ii)overflow: too big for the bits
How many bits does (b)'s true answer need?

179 + 120 = 299 > 255, so 9 bits: there is a carry out.

Faster way for (a)?

Flip and add 1 gives a small positive number to read: 68.

5 Now solve it have a go on paper first, then open the worked solution
  1. (a)(iii) Flip: 0000 0100 0011; add 1: 0000 0100 0100 = 68 M1
  2. So the value is −68 A1
  3. (b)(i) column by column, carries shown:
  4. Answer (1) 0010 1011 B1
  5. (b)(ii) An overflow (error) occurs B1: the answer cannot be represented in the number of bits available / is larger than the maximum the register can store B1
The (1) is the carry out of the 8-bit register: 299 doesn't fit in 8 unsigned bits.
1286432168421
Carries1111
A10110011
B+01111000
Answer100101011
6 Check it does the answer make sense?

(a): −2048 + 1024 + 512 + 256 + 128 + 32 + 16 + 8 + 4 = −68 ✓ (the scheme's Method 2).

Example 3 · Adding three numbers with overflow (Paper 1, 3 marks) ★★ Medium
9618/11/M/J/24 Q7Paper 1 · Theory fundamentals3 marksFull size
Complete the binary addition. Show your working. 10011110 + 01100001 + 00011001 [3]
1 Read it with me what is actually happening?

Three rows instead of two. A column can now total 4 or 5 with carries, so a carry can be worth 2 columns: 3 marks are working, answer and showing the overflow.

  • show your workingcarries visible
  • three numbersa column total can be up to 3 + carries
2 What is it asking for? the target, part by part
  • Wholethe 8-bit sum3: working, answer, overflow shown
3 What do we know? everything the question gives us
  • 1001 1110
  • 0110 0001
  • 0001 1001
  • 158 + 97 + 25 = 280
4 Plan the route work backwards from what we want
FindKey ideaAlready have itWork out firstTrap
  • Sum8 bits
    • Two at a timeadd the first two, then the third
    • Trapforgetting the final carry
Can 280 fit in 8 bits?

No: the largest is 255, so expect a carry out → overflow.

Simplest safe method?

Add the first two numbers, then add the third to that result.

5 Now solve it have a go on paper first, then open the worked solution
  1. First two: 1001 1110 + 0110 0001 = 1111 1111 (no carries at all)
  2. Then 1111 1111 + 0001 1001: every column carries
  3. Answer 0001 1000 B1, working with carries B1, overflow clearly indicated (the (1) carried out) B1
The second addition. Writing it as two separate sums keeps every carry a single 1.
1286432168421
Carries11111111
1111 111111111111
0001 1001+00011001
Answer100011000
6 Check it does the answer make sense?

158 + 97 + 25 = 280; 280 − 256 = 24 = 0001 1000 ✓

Example 4 · Adding 15, then taking 10 away - the right way round (Paper 1, 6 marks) ★★★ Hard
9618/11/M/J/21 Q1Paper 1 · Theory fundamentalsPart (c)6 marksFull size
(c) One of the colours used in the image has the hexadecimal colour code #FC238A. FC is the amount of red, 23 is the amount of green and 8A is the amount of blue. (i) Convert the hexadecimal code FC into denary. [1] (ii) The amount of green in binary is 00100011. This has the denary number 15 added to it to create a second colour. Add the denary number 15 to 00100011 and give your answer in binary. Perform the addition in binary. Show your working. [3] (iii) Hexadecimal 23 in two's complement representation is 00100011. The denary number 10 needs to be subtracted from this value. Subtract the denary number 10 from 00100011. Give your answer in binary. Show your working. [3]

Why it is hard: the report: “a common error was to perform the subtraction the wrong way round and take the two's complement of hexadecimal 23 instead of the two's complement of denary 10”.

1 Read it with me what is actually happening?

A colour code gives the setting: green = hex 23 = 0010 0011. Two binary calculations follow, each 3 marks: convert the denary number, do the arithmetic in binary, answer.

  • perform the addition in binaryno marks for denary arithmetic
  • subtract 10 from 2323 − 10: it is 10 that becomes negative
2 What is it asking for? the target, part by part
  • (i)FC in denary1
  • (ii)35 + 15 in binary3
  • (iii)35 − 10 in binary3
3 What do we know? everything the question gives us
  • FC(i)
  • 0010 0011 (= 35)(ii), (iii)
  • 15, 10denary
4 Plan the route work backwards from what we want
FindKey ideaAlready have itWork out firstTrap
  • (iii)35 − 10
    • −100000 1010 → flip → +1 = 1111 0110
    • Add0010 0011 + 1111 0110
    • Trapmaking 0010 0011 negative
FC in denary?

15 × 16 + 12 = 252.

Which number gets the flip-and-add-1?

The one being subtracted: 10.

5 Now solve it have a go on paper first, then open the worked solution
  1. (i) FC = 15 × 16 + 12 = 252 B1
  2. (ii) 15 = 0000 1111 B1; add with carries shown B1; answer 0011 0010 B1
  3. (iii) −10 = 1111 0110 B1; add 0010 0011 + 1111 0110 B1; discard the carry: 0001 1001 B1
1286432168421
Carries1111
3500100011
15+00001111
(ii)00110010
(iii): the carry out of the left column is ignored.
1286432168421
Carries11111
3500100011
−10+11110110
(iii)100011001
6 Check it does the answer make sense?

(ii) 35 + 15 = 50 = 0011 0010 ✓. (iii) 35 − 10 = 25 = 0001 1001 ✓.

Summary

  • Sign bit (MSB): 0 positive, 1 negative.
  • One's complement: flip all the bits of the positive number. Two zeros; 8-bit range −127 to 127.
  • Two's complement: MSB worth −128 (8-bit), −2048 (12-bit). Negative: flip the positive and add 1. 8-bit range −128 to 127.
  • Addition: carry at 2. Subtraction: A + (−B), discard the final carry; or borrow.
  • Overflow: the result does not fit the bits. Unsigned: carry out. Two's complement: same-sign inputs, other-sign answer.
If you see…do this
“two's complement” and MSB 1negative: −128 + the rest, or flip + 1, then a minus sign
“12-bit”MSB −2048; pad positives to 12 bits before flipping
“one's complement of −n”flip +n, and stop
“subtract x from y”y − x: make x negative and add
“show your working”carries / borrows visible, answer labelled
“name and describe the error”overflow + the result needs more bits than are available

Can I do this?

Anything unticked: revise that section first. All ticked: take the quiz.

Quiz

The multiple-choice and guided questions need JavaScript. The concept checks and exam practice below work without it.

Concept checks

Answer each one in your head first, then open it.

1Why does flipping the bits and adding 1 give the negative?Show answer

A number plus its flip is all 1s (1111 1111 = −1 in two's complement). So x + flip(x) = −1, which means flip(x) + 1 = −x.

2Why can adding a positive and a negative never overflow?Show answer

The answer always lies between the two numbers, and both of them fit in the bits, so the answer fits too.

3Why is a carry out an overflow for unsigned numbers but not for two's complement?Show answer

Unsigned: the carry is a real 256s bit that has nowhere to go. Two's complement: adding −B is like adding 256 − B; the extra 256 is exactly the carry out, so dropping it gives the right answer.

4How can the same 8 bits be both 200 and −56?Show answer

Bits have no meaning on their own. The program decides whether a register holds unsigned or two's complement data; the two readings differ by 256.

Exam-style practice

New questions, not used above. Do them on paper, then mark your work against the official mark scheme.

Q19618/12/M/J/25 Q2Paper 1 · Theory fundamentals3 marksFull size
(b)(i) Convert the two's complement binary integer 11100010 into denary. [1] (ii) Write the smallest and the largest two's complement binary integers that can be represented in 8 bits. [2]
Show the mark scheme
PartAnswer / workingMarksGuidance
(b)(i)−30B1−128 + 64 + 32 + 2
(b)(ii)Smallest: 1000 0000B1
Largest: 0111 1111B1bit patterns, not −128 / 127
Total: 3 marks
Q29618/12/M/J/24 Q7Paper 1 · Theory fundamentals3 marksFull size
(b) Subtract the denary number 10 from the denary number 100 using binary subtraction. Show your working. [3]
Show the mark scheme
PartAnswer / workingMarksGuidance
(b)Converting 100 to binary 0110 0100 and 10 to binary 0000 1010B1
Method: converting 10 to −10 (1111 0110) and adding // direct subtraction with borrows shownB1
Correct answer 0101 1010B1= 90
Total: 3 marks
Q39618/11/O/N/24 Q1Paper 1 · Theory fundamentals4 marksFull size
(b)(ii) Convert the two's complement binary number 100110010111 into denary. [1] (c) Subtract the denary number 23 from the two's complement binary number 01001010. Perform this calculation using binary subtraction. Show your working. [2] (d) State one reason why binary addition and subtraction can result in overflow. [1]
Show the mark scheme
PartAnswer / workingMarksGuidance
(b)(ii)−1641B112-bit: −2048 + 256 + 128 + 16 + 4 + 2 + 1
(c)Working: 23 = 0001 0111, so −23 = 1110 1001; 0100 1010 + 1110 1001 // direct subtractionB1
Answer 0011 0011B1= 51
(d)The answer cannot be represented in the number of bits available // is larger than the maximum (or smaller than the most negative) number the register can storeB1
Total: 4 marks
Q49618/12/M/J/22 Q3Paper 1 · Theory fundamentals3 marks

(e) Convert the denary numbers 127 and 12 to 8-bit binary and then perform the subtraction 12 − 127 in binary.

Show your working.

  1. 127 in binary ……   12 in binary ……   12 − 127 in binary ……
    [3]
Show the mark scheme
PartAnswer / workingMarksGuidance
(e)127 = 0111 1111 and 12 = 0000 1100B1all 8 bits
Working, e.g. two's complement of 127 = 1000 0001, added to 0000 1100B1
Answer: 1000 1101B1= −115
Total: 3 marks

Examiner tip 12 − 127 is negative, so the answer starts with a 1 and there is no carry out to drop.

Q59618/13/M/J/25 Q7Paper 1 · Theory fundamentals3 marksFull size
(b) Complete the following binary addition. Show your working. Include any overflow bit(s). 11110101 + 10110001 [1] (c) Subtract the binary number 00011110 from the binary number 01100100 using binary subtraction. Show your working. [2]
Show the mark scheme
PartAnswer / workingMarksGuidance
(b)(1) 1010 0110B1the overflow bit must be shown
(c)Binary subtraction shown (direct with borrows, or adding the two's complement 1110 0010)B1
Answer 0100 0110B1100 − 30 = 70
Total: 3 marks

Your progress on this note is saved when JavaScript is on.