Syllabus: AS Level Computer Science
1.1 Free

Data representation

Number systems, binary, hexadecimal, BCD, two's complement and character sets.

Representing numbers

Computers store everything as binary. For whole numbers you can use:

  • Unsigned binary for numbers that are never negative.
  • Two's complement for positive and negative numbers.

Two's complement in three steps

To write -13 in 8 bits:

  1. 1Write +13 in binary: 00001101
  2. 2Invert every bit: 11110010
  3. 3Add 1: 11110011

So -13 is 11110011.

Binary coded decimal (BCD)

Each denary digit is stored in its own 4-bit group. The number 259 becomes:

0010 0101 1001
  2    5    9

BCD is easy to read and display but uses more bits than pure binary.

Check yourself

  1. 1Write -20 in 8-bit two's complement.
  2. 2Write 4071 in BCD.

Answers: 1) 11101100 2) 0100 0000 0111 0001