TechTayari

S13 · Computer Studies II · Grade 11 · ages 16–17

Number Systems & Codes

Data representation

Grade 11 · 1.1 Data RepresentationCBE strandFree · works offline

▶ Start the interactive lesson

The full lesson adds narration, an interactive mission and a 10-question bank, and the quiz explains any mistakes.

Four number systems

Computers store everything as binary (base 2: digits 0 and 1). People use decimal (base 10). Programmers often use octal (base 8: digits 0–7) and hexadecimal (base 16: digits 0–9 then A–F, where A = 10 and F = 15), because they are short ways to write long binary numbers.

Decimal to binary

Divide by 2 again and again, writing down each remainder, then read the remainders from the bottom up. 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1, so 13 = 1101 in binary. The same method works for octal (divide by 8) and hex (divide by 16).

Back to decimal with place values

Each place is worth a power of the base. In binary the places are 8, 4, 2, 1 from the left: 1101 = 8 + 4 + 0 + 1 = 13. In hex the places are 256, 16, 1: 2F = 2 × 16 + 15 = 47.

Binary, octal and hex shortcuts

One hex digit is exactly 4 bits, and one octal digit is exactly 3 bits. So group binary from the right: 1111 1010 = FA in hex, and 011 111 010 = 372 in octal. This is why hex is used for colours (#FF0000 is red) and memory addresses.

Character codes: ASCII, EBCDIC, BCD

Text is stored as numbers using a coding scheme. ASCII gives each character a code (A = 65, a = 97, 0 = 48). EBCDIC is an older scheme used on IBM mainframes. BCD (binary-coded decimal) stores each decimal digit in its own 4 bits: 59 becomes 0101 1001. Unicode extends ASCII to cover every language, including emoji.

Key points

  • Computers use binary; people use decimal; programmers also use octal and hex.
  • Hex digits go from 0 to 9, then A to F, where F means fifteen.
  • To convert decimal to binary, keep dividing by two and read the remainders upwards.
  • Binary place values are 8, 4, 2 and 1, doubling each time.
  • One hex digit is four bits, and one octal digit is three bits.
  • ASCII codes the capital letter A as 65.
  • BCD stores each decimal digit in its own four bits.

Try it for real: Convert like a computer

  • Convert your age and the day of the month you were born into binary, then into hex.
  • Use the explainer above to build the ASCII code for the first letter of your name.
▶ Start the interactive lesson