A-level Computer Science revision · Data representation

Signed binary and binary arithmetic

The idea

Negative integers can be stored with sign and magnitude (the left bit is the sign) or two's complement (the left bit has a negative place value, −128 in 8 bits). To negate in two's complement, flip all bits and add 1. Binary addition carries 1 when a column totals 2; an overflow occurs if the result needs more bits than available.

  1. Two's complement: left bit worth −128 in 8 bits.
  2. Negate: invert bits, add 1.
  3. Add column by column with carries.

Watch out In 8-bit two's complement the range is −128 to +127, not −127 to +127.

See it worked

Worked example

Write −20 in 8-bit two's complement.

  1. +20 = 0001 0100.
  2. Invert: 1110 1011.
  3. Add 1: 1110 1100.

Answer 1110 1100

Your turn

Question 12 marks

What denary value does the 8-bit two's complement number 1111 1010 represent?

Question 22 marks

Add the unsigned binary numbers 0101 1001 and 0011 0110, and give the result in denary.

Question 31 mark

What is the range of 8-bit two's complement integers?

Choose one

A-level Computer Science Pro, OCR H446

A-level Computer Science Pro

£119 once

Price rises to £199 on 1 January. Save £80 by joining before then.

At least 12 months of access

By paying you agree to our Terms and get access straight away, which ends your 14-day cancellation right.

No VAT is charged.

Independent practice for OCR A-level Computer Science (H446), not endorsed by OCR.

Privacy · Terms