Data Representation
Logical shifts and two's complement
In this note
- 1.1.5Perform logical left and right shifts (one or several places) on a positive 8-bit binary integer.
- 1.1.5Explain the effect of a shift: multiply or divide by 2, 4, 8 …, and what happens to bits that fall off.
- 1.1.6Use two's complement to represent positive and negative 8-bit integers, in both directions.
Before this: binary addition and overflow. Next: Text, sound and images.
The notes: every idea from the start, with our own examples.
What you should already know
8-bit place values
128 64 32 16 8 4 2 1. The leftmost bit is the most significant bit (MSB, worth the most); the rightmost is the least significant bit (LSB, worth 1).
Quick check: what is the MSB of 0100 0001 worth if it is 1?
128.
Multiplying by 10 in denary
Moving every digit one place left multiplies a denary number by 10: 36 → 360. In binary, one place left multiplies by 2.
Quick check: what does moving 2 places left do in denary?
Multiplies by 100.
Logical shifts
A logical shift moves every bit in a register a set number of places to the left or to the right. The register stays 8 bits wide, so:
- bits that move off the end of the register are lost;
- the empty places at the other end are filled with 0s.
Logical left shift
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |||
|---|---|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | ||
| After | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
General methodLogical left shift by n places
- Move every bit n places to the left.
- The n bits at the left end (the most significant bits) are lost.
- Fill the n empty places on the right with 0s.
- Effect: the number is multiplied by 2ⁿ (1 place × 2, 2 places × 4, 3 places × 8), as long as no 1s were lost.
Logical right shift
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |||
|---|---|---|---|---|---|---|---|---|---|---|
| Before | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | ||
| After | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
General methodLogical right shift by n places
- Move every bit n places to the right.
- The n bits at the right end (the least significant bits) are lost.
- Fill the n empty places on the left with 0s.
- Effect: the number is divided by 2ⁿ (1 place ÷ 2, 2 places ÷ 4, 4 places ÷ 16).
When bits that are 1 fall off
If a 1 is pushed off the end, the answer is no longer exactly × or ÷ 2ⁿ: the value becomes incorrect / inaccurate.
| Shift | Before | After | What happened |
|---|---|---|---|
| right 1 | 0000 1101 (13) | 0000 0110 (6) | 13 ÷ 2 = 6.5, but the 1 on the right was lost: only the whole number 6 is left |
| left 1 | 1100 0011 (195) | 1000 0110 (134) | 195 × 2 = 390 needs 9 bits; the MSB 1 was lost, so the result is wrong |
Try it yourself
Show working
- 13 × 8 = 104 = 0110 1000
Answer 0110 1000
Show working
- 88 ÷ 8 = 11
Answer 0000 1011
Show answer
Answer It is divided by 16 (2⁴)
Two's complement: negative numbers
Ordinary binary can only hold positive numbers. Two's complement lets one 8-bit register hold positive and negative numbers. The trick: the most significant bit is worth −128 instead of +128.
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |||
|---|---|---|---|---|---|---|---|---|---|---|
| −45 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |
The sign bit
MSB 0 → the number is positive (or 0). MSB 1 → the number is negative.
Positive numbers
Exactly the same as ordinary binary, with a 0 at the front: 45 = 0010 1101.
Range
8-bit two's complement holds −128 to +127: 1000 0000 = −128 and 0111 1111 = +127.
−1
1111 1111 = −128 + 127 = −1. All 1s is −1, not −255.
Denary to two's complement
Method A: flip and add 1
General methodFlip and add 1
- Write the positive number in 8-bit binary.
- If the number is positive, stop: that is the answer.
- If negative, flip every bit (0 → 1, 1 → 0).
- Add 1 to the result.
Example Convert −45 to 8-bit two's complement.
Write 45, flip every bit, add 1.
- 45 = 0010 1101
- flip: 1101 0010
- add 1: 1101 0011
Answer 1101 0011
Method B: start from −128
General methodStart from −128
- Put a 1 in the −128 column.
- Work out what must be added to −128 to reach the number: −45 − (−128) = 83.
- Write 83 in the other seven columns: 64 + 16 + 2 + 1.
Example Convert −45 to 8-bit two's complement.
−128 + 83 = −45.
- 83 = 101 0011 in the 7 columns
Answer 1101 0011
Two's complement to denary
General methodTwo's complement to denary
- Look at the MSB. If it is 0, convert as ordinary binary.
- If it is 1, the number is negative: add the place values with the MSB worth −128.
- (Or: flip every bit, add 1, convert, and put a minus sign in front.)
Example Convert the two's complement integer 1110 1100 to denary.
MSB is 1, so the first column is −128.
- −128 + 64 + 32 + 8 + 4
Answer −20
Try it yourself
Show working
- 78 = 0100 1110
- flip: 1011 0001
- +1: 1011 0010
Answer 1011 0010
Show working
- −128 + 32 + 16 + 4 + 2 + 1 = −73
Answer −73
Show working
- positive: ordinary binary with 0 at the front
Answer 0010 1101
Summary
- Logical shift: every bit moves left or right; bits that fall off are lost; 0s fill the empty places.
- Left shift n places = × 2ⁿ; right shift n places = ÷ 2ⁿ. If 1s are lost, the result is inaccurate / wrong.
- Two's complement: the MSB is worth −128. MSB 1 = negative. Range −128 to +127.
- Negative denary → two's complement: write the positive in binary, flip every bit, add 1.
- Two's complement → denary: −128 + the other place values (when the MSB is 1).
If you see …
- "state the effect" of a shift× or ÷ by 2ⁿ, and bits lost → may be inaccurate
- "describe the process" of a shiftbits move, MSB / LSB lost, 0s added at the other end
- a negative number to storetwo's complement: flip and add 1, and show it
Question types, what the examiner gives marks for, and real past-paper questions solved.
Ways they test it
Type 1 Do the shift
"Give the 8-bit binary number stored after a logical left shift of three places" [1]
Spot it a register and a number of places.
- Copy the 8 bits, move them, fill with 0s, count that you still have 8 bits.
Type 2 Effect of the shift
"State one effect this logical shift has on the binary number" [1] / "State the mathematical effect of a right shift of four places" [2]
Spot it "effect".
- Multiplied / divided by 2ⁿ (give the number: by 8, by 16).
- Bits are lost, so the value may become incorrect.
Type 3 Describe the process
"Describe the process of the logical left shift" [2]
Spot it "describe" + "process".
- Every bit is moved left (by the number of places).
- The leftmost / most significant bit is lost.
- A 0 is added as the rightmost / least significant bit.
Type 4 Convert to or from two's complement
"Complete the register for −78. Show all your working" [2]
Spot it a negative denary number or a binary integer starting with 1.
- 1 mark for a working method (flip and add 1, or −128 + …).
- 1 mark for the correct answer.
Type 5 Name it
"Give the name of the number system used to represent negative binary integers" [1]
Spot it "negative".
- Two's complement.
What the examiner looks for
"Describe the process of a logical left shift" [2] + "State the effect" [1]
Marking points (one mark each, up to the marks shown)
- Each / every bit in the binary number is shifted / moved to the left
- The leftmost / most significant bit is lost
- A 0 is added as the rightmost / least significant bit
- Effect: the binary integer is multiplied by 2 (per place)
Keywords moved left most significant bit lost 0 added multiplied by 2
Two's complement conversion [2]
Marking points (one mark each, up to the marks shown)
- One mark for a full method of working, e.g. conversion to binary then flipping and adding 1
- One mark for the correct 8-bit answer
Keywords flip add 1 −128
Too vague an answer with no working (loses the method mark); fewer than 8 bits
The effect of a right shift
- It is divided by 8
- The value becomes incorrect / inaccurate because the rightmost bits are lost
- It gets smaller
- It is divided by 3
Give the exact operation: 3 places = ÷ 2³ = ÷ 8. "Smaller" is not specific enough.
From: 2210/12/M/J/23 Q2(b)(ii) mark scheme
Past-paper questions, solved

How to start For (c) move every bit two places left and add two 0s. For (d) write 99 in binary first, then flip and add 1.
Show a full-mark answer and the mark scheme
(c) 1110 0011 → 1000 1100 (the two 1s on the left are lost).
(d) 99 = 0110 0011 → flip: 1001 1100 → add 1: 1001 1101. Check: −128 + 16 + 8 + 4 + 1 = −99.
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| 2(c) | 1 0 0 0 1 1 0 0 | B1 | |
| 2(d) | suitable working method, e.g. flip and add 1 | M1 | |
| 2(d) | 1001 1101 | A1 | |
| Total: 3 marks | |||

How to start The MSB of 10110111 is 1, so it is negative: start from −128. 45 is positive, so it is plain binary. Four places right = ÷ 2⁴.
Show a full-mark answer and the mark scheme
(b)(i) −128 + 32 + 16 + 4 + 2 + 1 = −73 (or flip 1011 0111 → 0100 1000, add 1 → 0100 1001 = 73, so −73).
(b)(ii) 0010 1101
(c) The integer is divided by 16.
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| 8(b)(i) | working, e.g. flip and add 1: 10110111 = 01001001 | M1 | |
| 8(b)(i) | −73 | A1 | |
| 8(b)(ii) | 00101101 | B1 | |
| 8(c) | divide · … by 16 // 2⁴ | B2 | one mark each |
| Total: 5 marks | |||

How to start "Describe the process" wants the three things that physically happen to the bits; "effect" wants the maths.
Show a full-mark answer and the mark scheme
(d)(i) Every bit in the integer is moved one place to the left. The leftmost (most significant) bit is lost and a 0 is added as the rightmost (least significant) bit.
(d)(ii) The integer is multiplied by 2.
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| 3(d)(i) | Any two: every bit is shifted left · the leftmost / MSB is lost · a 0 is added as the rightmost / LSB | B2 | |
| 3(d)(ii) | The binary integer is multiplied by 2 | B1 | |
| Total: 3 marks | |||
Common mistakes
- ✗ Shifting and ending up with 9 or 7 bits✓ Always exactly 8 bits after the shiftLost bits are gone; new places are 0s.
- ✗ "Right shift of 3 divides by 3"✓ Divides by 2³ = 8Each place is a factor of 2.
- ✗ Flipping the bits and forgetting to add 1✓ Flip, THEN add 1Flip alone gives one's complement, which is not on the syllabus.
- ✗ Writing −73 as 1100 1001 (73 with a 1 in front)✓ 1011 0111Two's complement is not "sign and size".
- ✗ No working for two's complement✓ Show the flip and the +1One of the two marks is for the method.
Practice
Practice: easy, medium, hard
Easy
Show answer
Answer 0100 1010
Show answer
Answer 0011 0010
Show answer
Answer negative (MSB is 1)
Medium
Show working
- 25 = 0001 1001
- flip 1110 0110
- +1 1110 0111
Answer 1110 0111
Show working
- −128 + 8 + 4 + 2
Answer −114
Show working
- 203 ÷ 4 = 50.75, the register holds 50
Answer 0011 0010: the two 1s on the right were lost
Hard
Show working
- 22 = 0001 0110
- flip 1110 1001
- +1 1110 1010
Answer 1110 1010
| Part | Answer / working | Marks | Guidance |
|---|---|---|---|
| flip and add 1 shown | M1 | ||
| 1110 1010 | A1 | ||
| Total: 2 marks | |||
Show answer
Answer −128 = 1000 0000; +127 = 0111 1111
Show answer
Answer 1011 0000 = 176; no 1s were lost (22 × 8 = 176)
Can I do this?
- I can do left and right logical shifts of any number of places.
- I can state the effect of a shift (× or ÷ 2ⁿ, bits lost).
- I can convert a negative denary number to 8-bit two's complement, with working.
- I can convert a two's complement integer to denary.
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.
Your progress on this note is saved when JavaScript is on.
⬇️ Download this chapter as a PDF: Full notes