haya.Learning made clear
Unit I · Computer and hardware systems
10 min readConcept sheetOften a 5-mark calculation

Internal data representation and number systems

Inside a computer everything is stored as binary digits (0 and 1); number systems and character codes turn these bits into numbers and text.

BitOne binary digit: 0 or 1
Byte8 bits: about one character
BasesBinary 2, octal 8, decimal 10, hexadecimal 16
Text codesASCII (English), Unicode (all scripts, incl. Sinhala and Tamil)

Why binary?

A computer is built from millions of tiny electronic switches. Each switch is either off (0) or on (1), so two digits are enough. Eight bits make a byte. One byte can hold 2⁸ = 256 different patterns, enough for one letter, digit or symbol.

The four number systems

SystemBaseDigits usedExample
Binary20, 11011₂
Octal80 to 717₈
Decimal100 to 9245₁₀
Hexadecimal160 to 9, then A=10, B=11, C=12, D=13, E=14, F=153F₁₆

Decimal to binary: divide by 2

Problem

Convert 45₁₀ to binary.

Working
  1. 45 ÷ 2 = 22, remainder 1
  2. 22 ÷ 2 = 11, remainder 0
  3. 11 ÷ 2 = 5, remainder 1
  4. 5 ÷ 2 = 2, remainder 1
  5. 2 ÷ 2 = 1, remainder 0
  6. 1 ÷ 2 = 0, remainder 1
  7. Read the remainders from the bottom up: 101101
  8. Check: 32 + 8 + 4 + 1 = 45
Answer

45₁₀ = 101101₂

Binary to decimal: use place values

Problem

Convert 110101₂ to decimal.

Working
  1. Place values from the right: 1, 2, 4, 8, 16, 32
  2. Write each bit under its place value: 32→1, 16→1, 8→0, 4→1, 2→0, 1→1
  3. 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1
  4. = 32 + 16 + 0 + 4 + 0 + 1 = 53
Answer

110101₂ = 53₁₀

Decimal to octal: divide by 8

Problem

Convert 100₁₀ to octal.

Working
  1. 100 ÷ 8 = 12, remainder 4
  2. 12 ÷ 8 = 1, remainder 4
  3. 1 ÷ 8 = 0, remainder 1
  4. Read the remainders from the bottom up: 144
  5. Check: 1×64 + 4×8 + 4×1 = 64 + 32 + 4 = 100
Answer

100₁₀ = 144₈

Decimal to hexadecimal: divide by 16

Problem

Convert 250₁₀ to hexadecimal.

Working
  1. 250 ÷ 16 = 15, remainder 10
  2. 15 ÷ 16 = 0, remainder 15
  3. Read from the bottom up: 15, 10
  4. Change to hex digits: 15 = F, 10 = A
  5. Check: F×16 + A×1 = 15×16 + 10 = 240 + 10 = 250
Answer

250₁₀ = FA₁₆

Binary to octal and hexadecimal: group the bits

Problem

Convert 10111110₂ to octal and to hexadecimal.

Working
  1. Octal: group in 3s from the right, adding a 0 in front: 010 111 110
  2. 010 = 2, 111 = 7, 110 = 6, so the answer is 276₈
  3. Hexadecimal: group in 4s from the right: 1011 1110
  4. 1011 = 11 = B, 1110 = 14 = E, so the answer is BE₁₆
  5. Check in decimal: 2×64 + 7×8 + 6 = 128 + 56 + 6 = 190
  6. and B×16 + E = 11×16 + 14 = 176 + 14 = 190
Answer

10111110₂ = 276₈ = BE₁₆ = 190₁₀

Character codes

CodeSizeWhat it covers
ASCII7 bits, 128 characters (extended ASCII uses 8 bits)English letters, digits and symbols. 'A' = 65 = 01000001
EBCDIC8 bitsUsed mainly on IBM mainframe computers
Unicode1 to 4 bytes per character (UTF-8 form)Almost every writing system, including Sinhala and Tamil, plus symbols and emoji
In Sri Lankan business

Sri Lankan government and business websites can show Sinhala, Tamil and English on the same page because all three scripts are coded in Unicode. Web designers also write colours in hexadecimal, for example #FFFFFF for white.

Exam angle

Structured question: “Convert 156₁₀ into binary, octal and hexadecimal. Show your working.” 156₁₀ = 10011100₂ = 234₈ = 9C₁₆. Show the repeated division by 2, group the bits in 3s and 4s, and check by place values.

Short answer: “What is a byte?” A group of 8 bits. It can hold 256 different patterns, enough to store one character.

Short answer: “Why do computers use the binary system?” Computer circuits are switches with two states, off and on, which match the two binary digits 0 and 1.

Remember it

To go from decimal: divide and read the remainders upward. To come back to decimal: multiply by place values and add. Shortcut: binary to octal in 3s, binary to hex in 4s.