Data representation

Computer Science AS · Information representation. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science AS topics

The idea

Everything in a computer is stored as binary. You must move easily between denary, binary, hexadecimal and Binary Coded Decimal (BCD), where each denary digit gets its own 4-bit code.

Negative integers are stored in two's complement: the left-most bit has a negative place value, so in 8 bits it is worth −128. Subtraction is done by adding the two's complement of the number. If a result is too big or too small for the number of bits, overflow occurs and the answer is wrong.

Characters are stored as codes from a character set: ASCII, extended ASCII or Unicode. File sizes use binary prefixes (kibi, mebi) or decimal prefixes (kilo, mega), and these are not the same.

Rules to remember

Common mistake

Students treat a BCD code as one pure binary number. In BCD each group of 4 bits is a separate denary digit, so 0001 0010 is 12, not 18.

Worked example

Convert the denary number 181 to hexadecimal and to 8-bit binary.

  1. Divide by 16: 181 ÷ 16 = 11 remainder 5 (11 × 16 = 176, 181 − 176 = 5).
  2. 11 is the hex digit B and 5 is the hex digit 5, so the hex value is B5.
  3. Write each hex digit as 4 bits: B = 1011, 5 = 0101, giving 1011 0101.
  4. Check: 128 + 32 + 16 + 4 + 1 = 181.

Answer: 181 in denary is B5 in hexadecimal and 10110101 in binary.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

Multimedia →Take a Computer Science AS test