DR

1.1 Data Representation

Understanding binary, hexadecimal, character sets, and data storage in computers

Learning Objectives

By the end of this lesson, you will be able to:

  • Show understanding of binary magnitudes and difference between binary prefixes and decimal prefixes
  • Show understanding of the basis of different number systems (binary, denary, hexadecimal)
  • Perform binary addition and subtraction using positive & negative binary integers
  • Describe practical applications where BCD and Hexadecimal are used
  • Show understanding of character data representation in internal binary form (ASCII, extended ASCII, Unicode)
  • Understand and use different prefixes: kibi/kilo, mebi/mega, gibi/giga, tebi/tera
  • Use binary, denary, hexadecimal number bases and BCD and one's and two's complement representation
  • Convert integer values between different number bases and representations
  • Show understanding of how overflow can occur in binary arithmetic
  • Become familiar with ASCII, extended ASCII and Unicode character sets

Key Terms

Binary Number System

Number system with base 2 using only digits 0 and 1

Denary Number System

Decimal number system with base 10 using digits 0-9

Hexadecimal Number System

Number system with base 16 using digits 0-9 and A-F

Bit

Smallest unit of data in computing (binary digit: 0 or 1)

Byte

Group of 8 bits, basic unit for storing data

Nibble

Group of 4 bits (half a byte)

Two's Complement

Method for representing signed integers in binary

Binary Coded Decimal (BCD)

Encoding where each decimal digit is represented by 4 binary bits

ASCII

American Standard Code for Information Interchange (7-bit character encoding)

Unicode

Universal character encoding standard supporting all languages

Overflow

Error that occurs when calculation produces result too large for storage

Code Point

Numerical value that represents a character in Unicode (e.g., U+0041 for 'A')

Number Systems

A number system is a way of representing amounts or quantity of something. Different number systems use different bases, which determine how many digits are available and how place values work.

10

Decimal (Denary)

Base 10 system using digits 0-9

Our everyday number system
2

Binary

Base 2 system using digits 0 and 1

How computers store data
16

Hexadecimal

Base 16 system using digits 0-9 and A-F

Compact representation of binary

Decimal (Denary) Number System

How It Works

The decimal system has base 10 because it uses 10 digits (0-9). Each position in a decimal number represents a power of 10:

8 2 7 4
(8×10³) + (2×10²) + (7×10¹) + (4×10⁰)
= (8×1000) + (2×100) + (7×10) + (4×1)
= 8000 + 200 + 70 + 4
= 8274

This is the number system we use in daily life for counting, money, measurements, etc.

Binary Number System

The binary system has base 2 and uses only two digits: 0 and 1. Each position represents a power of 2. Computers use binary because electronic circuits can easily represent two states (on/off, high/low voltage).

Binary Place Values
Power of 2 2⁵ 2⁴ 2⁰
Value 32 16 8 4 2 1

Binary Number Visualizer

Current Value: 0 (in decimal)

How it works: Each bit (binary digit) represents a power of 2. Click on bits to toggle them on (1) or off (0). The decimal value updates based on which bits are active.

Denary to Binary Conversion

To convert a denary number to binary, repeatedly divide by 2 and record the remainders. Read remainders from bottom to top.

Example: Convert 203₁₀ to Binary
Division Quotient Remainder
203 ÷ 2 101 1
101 ÷ 2 50 1
50 ÷ 2 25 0
25 ÷ 2 12 1
12 ÷ 2 6 0
6 ÷ 2 3 0
3 ÷ 2 1 1
1 ÷ 2 0 1

Reading remainders from bottom to top: 11001011₂
So, 203₁₀ = 11001011₂

Binary to Denary Conversion

To convert binary to denary, multiply each bit by its place value (power of 2) and sum the results.

Example: Convert 0011000111100110₂ to Denary
Place values: 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
Binary:      0   0   1   1   0   0   0   1   1   1   0   0   1   1   0

Add values where bit is 1:
8192 + 4096 + 256 + 128 + 64 + 32 + 4 + 2 = 12,774
So, 0011000111100110₂ = 12,774₁₀

Hexadecimal Number System

Hexadecimal (hex) has base 16 and uses 16 digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). It's commonly used in computing because one hex digit represents exactly 4 binary bits (a nibble), making it compact and readable.

Hexadecimal Digits
Decimal Binary Hexadecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010A
111011B
121100C
131101D
141110E
151111F

Hex to Binary Conversion

Convert hex number 45A to binary:

4 = 0100
5 = 0101
A = 1010 (since A = 10)
Result: 0100 0101 1010

Binary to Hex Conversion

Convert binary 10110101 to hex:

1. Split into groups of 4: 1011 0101
2. Convert each group:
  1011 = B
  0101 = 5
Result: B5

Hex to Denary Conversion

Convert hex 45A to denary:

Place values: 256 16 1
4 × 256 = 1024
5 × 16 = 80
A(10) × 1 = 10
Total: 1024 + 80 + 10 = 1114

Real-Life Example: Color Codes in Web Design

Hexadecimal in Web Colors
  • Web colors use hexadecimal notation: #RRGGBB
  • Each color (Red, Green, Blue) has 2 hex digits (00-FF)
  • #FF0000 = Maximum red, no green, no blue = Pure Red
  • #00FF00 = Pure Green
  • #0000FF = Pure Blue
  • #FFFFFF = Maximum all colors = White
Binary in Digital Storage
  • Every file on your computer is stored as binary
  • Photos, videos, documents - all 0s and 1s
  • A 1MB photo ≈ 8 million bits
  • MP3 files use binary compression to reduce size
  • When you save a file, it's converted to binary for storage

Activity 1: Number System Conversions

Convert the following numbers as indicated:

  1. Convert 156₁₀ to binary
  2. Convert 10101101₂ to denary
  3. Convert 3F₂₁₆ to binary
  4. Convert 11010111₂ to hexadecimal
  5. Convert 89₁₀ to hexadecimal

Hint: Use the division method for denary to binary, and remember that each hex digit equals 4 binary bits.

Solution:
  1. 156₁₀ = 10011100₂ (156 ÷ 2 = 78 R0, 78 ÷ 2 = 39 R0, 39 ÷ 2 = 19 R1, 19 ÷ 2 = 9 R1, 9 ÷ 2 = 4 R1, 4 ÷ 2 = 2 R0, 2 ÷ 2 = 1 R0, 1 ÷ 2 = 0 R1)
  2. 10101101₂ = 128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173₁₀
  3. 3F₂₁₆ = 3=0011, F=1111, 2=0010 → 0011 1111 0010₂
  4. 11010111₂ = D7₁₆ (1101=D, 0111=7)
  5. 89₁₀ = 59₁₆ (89 ÷ 16 = 5 R9, so 5 and 9 which is 59 in hex)

Activity 2: Binary Patterns

Answer the following questions about binary numbers:

  1. How can you tell if a binary number is odd just by looking at it?
  2. What is the largest decimal number you can represent with 8 bits?
  3. If a binary number ends with 0, is it even or odd?
  4. How many different values can be represented with 4 bits?
  5. What binary pattern represents the decimal number 0 in 8-bit representation?
Solution:
  1. A binary number is odd if its rightmost digit (least significant bit) is 1.
  2. With 8 bits, the largest decimal number is 255 (2⁸ - 1 = 256 - 1 = 255).
  3. If a binary number ends with 0, it is even (just like in decimal, numbers ending with 0, 2, 4, 6, 8 are even).
  4. 4 bits can represent 16 different values (2⁴ = 16), from 0 to 15.
  5. 0 in 8-bit binary is 00000000.

Check Your Understanding: Number Systems

Answer
  • [1 mark] The binary number system has base 2, using only digits 0 and 1.
  • [1 mark] It is used in computers because electronic circuits can easily represent two states (on/off, high/low voltage, true/false), making binary ideal for digital systems.
Answer
  • [1 mark] A = 10 in decimal = 1010 in binary
  • [1 mark] 3 = 0011 in binary
  • [1 mark] F = 15 in decimal = 1111 in binary
  • [Full answer] A3F₁₆ = 1010 0011 1111₂
Answer
  • [1 mark] Hexadecimal is more compact and readable than binary - one hex digit represents 4 binary bits.
  • [1 mark] It's easier for humans to work with and less prone to errors when reading/writing long sequences compared to binary.
Answer
  • [Working] Place values: 32, 16, 8, 4, 2, 1
  • [Working] Binary: 1(32), 0(16), 1(8), 1(4), 0(2), 1(1)
  • [1 mark] Calculation: 32 + 0 + 8 + 4 + 0 + 1 = 45
  • [Answer] 101101₂ = 45₁₀
Answer
  • [1 mark] A nibble is a group of 4 bits (half a byte).
  • [1 mark] One hexadecimal digit represents exactly one nibble (4 bits), which is why hex is a convenient way to represent binary data.

Binary Arithmetic & Representation

Computers perform arithmetic operations using binary numbers. Understanding binary addition, subtraction, and how to represent negative numbers is essential for computer science.

Binary Addition

Binary addition follows simple rules similar to decimal addition, but with only two digits (0 and 1).

Binary Addition Rules

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 0 with a carry of 1 (like 1 + 1 = 2, which is 10 in binary)
  • 1 + 1 + 1 = 1 with a carry of 1 (1+1+1 = 3, which is 11 in binary)

Example: Add 37₁₀ and 58₁₀ in Binary

First convert to binary:

37₁₀ = 00100101₂
58₁₀ = 00111010₂

Now add them:

Carry:
1 1 1
0 0 1 0 0 1 0 1   (37)
+ 0 0 1 1 1 0 1 0   (58)
0 1 0 1 1 1 1 1   (95)

Result: 01011111₂ = 95₁₀ ✓

Binary Subtraction

Binary subtraction can be done directly or using two's complement method. The direct method uses borrowing, similar to decimal subtraction.

Direct Binary Subtraction Rules

  • 0 - 0 = 0
  • 1 - 0 = 1
  • 1 - 1 = 0
  • 0 - 1 = 1 after borrowing (similar to 10 - 1 = 9 in decimal)

Example: Subtract 11₁₀ from 14₁₀ (Direct Method)

First convert to binary:

14₁₀ = 1110₂
11₁₀ = 1011₂

Subtract (with borrowing):

Borrow:
1 1
1 1 1 0   (14)
- 1 0 1 1   (11)
0 0 1 1   (3)

Steps: 0-1 needs borrow → 10-1=1, then 0-1 (after borrow) needs borrow → 10-1=1, then 0-0=0, then 0-1 (after borrow)=1 with borrow.

Two's Complement Subtraction Method

An easier method: Convert subtraction to addition using two's complement.

Example: 95 - 68

1. Convert to binary: 95 = 01011111, 68 = 01000100
2. Find two's complement of 68:
Invert bits: 10111011
Add 1: 10111100
3. Add 95 + (-68):
01011111 + 10111100 = 100011011
4. Ignore overflow bit (9th bit): 00011011 = 27₁₀ ✓

Representing Signed Integers

Computers need to represent both positive and negative numbers. There are two main methods: Sign and Magnitude and Two's Complement.

Sign and Magnitude Representation

In this method, the leftmost bit (most significant bit) is the sign bit:

  • 0 = positive number
  • 1 = negative number
  • The remaining bits represent the magnitude (absolute value)
Example: 8-bit Sign and Magnitude
+53 = 0 0110101 (0 for positive, then 53 in binary)
-53 = 1 0110101 (1 for negative, then 53 in binary)

Problem: Has two representations of zero (+0 and -0) and makes arithmetic complicated.

Two's Complement Representation

This is the standard method used in modern computers. It has several advantages:

  • Only one representation of zero
  • Simplifies arithmetic operations (addition/subtraction use same circuitry)
  • Range for n bits: -2ⁿ⁻¹ to +2ⁿ⁻¹ - 1
How to find two's complement:
1
Start with positive binary number
Example: +4 = 0100
2
Invert all bits (find one's complement)
0100 → 1011
3
Add 1 to the result
1011 + 1 = 1100
4
Result is negative number in two's complement
1100 = -4
Example: Represent -28 in 8-bit two's complement
1. +28 in binary: 00011100
2. Invert bits: 11100011
3. Add 1: 11100100
Result: -28 = 11100100₂

Overflow in Binary Arithmetic

Overflow occurs when a calculation produces a result that is too large to be represented within the available number of bits.

Overflow Visualization

1

8-bit maximum: 11111111₂ = 255₁₀
Adding 1 causes overflow

How it works: An 8-bit CPU can store numbers up to 255 (11111111). Adding 1 produces 100000000 (9 bits). The CPU drops the overflow bit (9th bit), resulting in 00000000 (0). So 255 + 1 = 0 (overflow error).

Modern CPUs and Overflow

Most modern PCs have 64-bit CPUs, which can handle numbers up to 18,446,744,073,709,551,615 (over 18 quintillion). Overflow is less common but still possible with very large calculations.

Real-Life Example: Video Game Scores

Classic Arcade Games
  • Early games like Pac-Man used 8-bit scores
  • Maximum score was 255 (11111111 in binary)
  • Getting 256 points caused overflow → score reset to 0
  • This was known as the "kill screen" or "max score bug"
Modern Banking Systems
  • Use Binary Coded Decimal (BCD) for accurate calculations
  • Avoid rounding errors with financial transactions
  • Each decimal digit stored as 4 binary bits
  • Ensures exact representation of monetary values

Activity 3: Binary Arithmetic Practice

Perform the following binary calculations:

  1. Add: 1011₂ + 1101₂
  2. Subtract: 1100₂ - 1011₂ (use direct method)
  3. Subtract using two's complement: 75₁₀ - 42₁₀
  4. Find two's complement representation of -19 in 8-bit
  5. What happens when you add 11111111₂ + 00000001₂? Does overflow occur?
Solution:
  1. 1011₂ + 1101₂ = 11000₂ (Check: 11+13=24, 11000₂=24)
  2. 1100₂ - 1011₂ = 0001₂ (12-11=1)
  3. 75-42=33. 75=01001011, 42=00101010, two's complement of 42=11010110, add: 01001011+11010110=100100001, ignore overflow: 00100001=33
  4. +19=00010011, invert: 11101100, add 1: 11101101 = -19
  5. 11111111₂ + 00000001₂ = 100000000₂ (9 bits). Yes, overflow occurs. In 8-bit, result would be 00000000 (0).

Check Your Understanding: Binary Arithmetic

Answer
  • [1 mark] Overflow occurs when a calculation produces a result that is too large to be represented within the available number of bits.
  • [1 mark] It happens when adding two numbers produces a carry beyond the most significant bit.
  • [1 mark] Example: In 8-bit binary, 255 (11111111) + 1 = 256 (100000000) but only 00000000 is stored, causing error.
Answer
  • [1 mark] Two's complement has only one representation of zero, while sign and magnitude has two (+0 and -0).
  • [1 mark] Arithmetic operations (addition and subtraction) are simpler and can use the same circuitry.
  • [1 mark] The range of representable numbers is symmetric (for n bits: -2ⁿ⁻¹ to +2ⁿ⁻¹ - 1).
Answer
  • [Method] For two's complement, the most significant bit has negative weight.
  • [Calculation] 10110001 = -128 + 0 + 32 + 16 + 0 + 0 + 0 + 1
  • [1 mark] = -128 + 32 + 16 + 1
  • [1 mark] = -128 + 49
  • [1 mark] = -79
Answer
Carry: 1 1 1 1
0 1 1 0 1 0 0 1 (105)
+ 0 0 1 1 0 1 1 0 (54)
1 0 0 1 1 1 1 1 (159)
  • [2 marks] Result: 10011111₂ = 159₁₀
  • [1 mark] No overflow occurs because both numbers are positive and result is within 8-bit range (0-255).
  • [1 mark] The 9th bit (carry out) is 0, indicating no overflow.
Answer
  • [1 mark] For n-bit two's complement, range is -2ⁿ⁻¹ to +2ⁿ⁻¹ - 1.
  • [1 mark] For 8 bits: -2⁷ to +2⁷ - 1 = -128 to +127.

Character Representation & Data Storage

Computers represent text using character encoding systems. The same binary pattern can represent different things depending on how it's interpreted - as a number, a character, or other data.

ASCII (American Standard Code for Information Interchange)

ASCII is a 7-bit character encoding standard that represents 128 characters, including:

ASCII Key Facts

  • 7-bit code = 2⁷ = 128 possible characters
  • Includes: uppercase/lowercase letters, digits 0-9, punctuation, control characters
  • 'A' = 65₁₀ = 01000001₂
  • 'a' = 97₁₀ = 01100001₂
  • Difference between 'A' and 'a': 6th bit changes (65 vs 97)

Extended ASCII (ASCII-8)

  • 8-bit extension of ASCII
  • 2⁸ = 256 possible characters
  • Adds additional symbols, accented characters, graphics characters
  • First 128 codes same as standard ASCII

ASCII Character Codes Visualization

Selected Character: - ASCII Code: - Binary: -

Patterns to notice: Uppercase A-Z are codes 65-90, lowercase a-z are 97-122, digits 0-9 are 48-57. Control characters (0-31) are non-printable.

Unicode

Unicode is a universal character encoding standard designed to support all languages and writing systems worldwide.

Unicode Key Features

  • Supports over 65,536 characters (initially 16-bit)
  • Now expanded to 32-bit (over 1 million possible characters)
  • Includes characters from all major languages: English, Chinese, Arabic, etc.
  • First 128 codes same as ASCII (backward compatibility)
  • Each character has a unique "code point" (e.g., U+0041 for 'A')

Code Points

  • Code point = U+ followed by hexadecimal number
  • U+0041 = 'A' (same as ASCII 65)
  • U+20AC = '€' (Euro symbol)
  • U+4E2D = '中' (Chinese character)
  • U+0000 to U+00FF = same as extended ASCII

Real-World Unicode Use

Websites & Internationalization
  • Websites display multiple languages on same page
  • Social media posts with emojis and mixed scripts
  • Operating systems support keyboard input for all languages
  • Search engines index content in any language
Emojis
  • Emojis are Unicode characters too!
  • 😀 = U+1F600 (Grinning Face)
  • ❤️ = U+2764 (Red Heart)
  • 📱 = U+1F4F1 (Mobile Phone)
  • Emojis use supplementary Unicode planes

Binary Coded Decimal (BCD)

BCD is an encoding where each decimal digit (0-9) is represented by 4 binary bits. This is different from regular binary representation of the whole number.

How BCD Works

Example: Decimal number 8503 in BCD:

Method 1 (unpacked): One byte per digit

00001000 (8)
00000101 (5)
00000000 (0)
00000011 (3)

Method 2 (packed): Two digits per byte

10000101 (8 and 5)
00000011 (0 and 3)

BCD Applications

Financial/Banking Systems
  • Accurate decimal calculations (no binary rounding errors)
  • Critical for monetary values (exact cents/pence)
  • Used in ATMs, banking software, accounting systems
Digital Displays
  • Calculators, digital clocks, electronic meters
  • Easy conversion to display individual digits
  • 7-segment displays use BCD for each digit
BCD Addition

BCD addition requires correction: If sum of two BCD digits > 9, add 6 (0110) to correct.
Example: 9+5 = 14. In binary: 1001+0101=1110 (invalid BCD). Add 0110: 1110+0110=00010100 = 14 in BCD.

The Data Interpretation Problem

Consider the binary pattern: 01000001

As a number
65

Binary to decimal conversion

As ASCII character
A

ASCII code 65 = 'A'

As part of an image
◼◼◼◼

Could be pixel intensity values

How does the computer know? By knowing where the data is stored (memory address) and what type of data is expected at that location. The same binary can represent different things depending on context!

Binary and Decimal Prefixes

Computer memory sizes use prefixes to indicate magnitude. There are two systems: decimal prefixes (based on powers of 10) and binary prefixes (based on powers of 2).

Decimal Prefixes (SI)

Based on powers of 10, used for data transmission rates

Prefix Symbol Factor Bytes
kiloK10³1,000
megaM10⁶1,000,000
gigaG10⁹1,000,000,000
teraT10¹²1,000,000,000,000

Binary Prefixes (IEC)

Based on powers of 2, used for memory/storage

Prefix Symbol Factor Bytes
kibiKi2¹⁰1,024
mebiMi2²⁰1,048,576
gibiGi2³⁰1,073,741,824
tebiTi2⁴⁰1,099,511,627,776

Conversion Examples

Convert 34,560 bytes to kibibytes:

34,560 ÷ 1,024 = 33.75 KiB

How many 2.4 MiB files fit on 4 GiB USB?

(4 × 1,024) MiB ÷ 2.4 ≈ 1,706 files
Common Confusion:

When you buy a "500GB" hard drive, it uses decimal gigabytes (500 × 10⁹ bytes).
Your computer shows it as ~465 GiB (500 × 10⁹ ÷ 2³⁰ ≈ 465.66).

Activity 4: Character Codes & Prefixes

Answer the following questions:

  1. What is the ASCII code for 'Z' in binary, decimal, and hexadecimal?
  2. How many characters can be represented using extended ASCII (8-bit)?
  3. Convert 16,384 bytes to kibibytes (KiB).
  4. What is the Unicode code point for the letter 'B'?
  5. Why is BCD used in financial systems instead of regular binary?
  6. What is the difference between a kilobyte (KB) and a kibibyte (KiB)?
Solution:
  1. 'Z' = ASCII 90 = 01011010₂ = 5A₁₆
  2. Extended ASCII (8-bit) can represent 256 characters (2⁸ = 256).
  3. 16,384 bytes ÷ 1,024 = 16 KiB (since 16,384 = 2¹⁴ and 1,024 = 2¹⁰, so 2¹⁴ ÷ 2¹⁰ = 2⁴ = 16)
  4. 'B' = U+0042 (Unicode code point in hexadecimal).
  5. BCD is used in financial systems because it represents decimal digits exactly without binary rounding errors, crucial for accurate monetary calculations.
  6. Kilobyte (KB) = 1,000 bytes (decimal prefix), Kibibyte (KiB) = 1,024 bytes (binary prefix).

Check Your Understanding: Character Representation

Answer
Similarities:
  • Both represent characters using unique numeric codes
  • First 128 codes (0-127) are identical in both systems
Differences:
  • ASCII is 7/8 bit (128/256 chars), Unicode is 16/32 bit (65,536+ chars)
  • ASCII supports mainly English, Unicode supports all world languages
Answer
  • [1 mark] BCD (Binary Coded Decimal) is an encoding where each decimal digit (0-9) is represented by 4 binary bits.
  • [1 mark] It is used in calculators and digital clocks because it's easier to convert individual digits for display.
  • [1 mark] Each digit can be directly mapped to a 7-segment display without complex binary-to-decimal conversion.
Answer
  • [1 mark] 1 GiB = 1,024 MiB
  • [1 mark] 2.5 GiB = 2.5 × 1,024 MiB
  • [1 mark] = 2,560 MiB
Answer
  • [1 mark] A Unicode code point is a numerical value that uniquely identifies a character in the Unicode standard.
  • [1 mark] It is represented as U+ followed by a hexadecimal number (usually 4-6 digits).
  • [1 mark] Example: U+0041 represents the character 'A' (same as ASCII 65).
Answer
  • [1 mark] The computer knows by the context - where the data is stored in memory and what type of data is expected at that location.
  • [1 mark] If it's in a memory location designated for text/characters, it's interpreted as 'A'. If in a location for numbers, it's interpreted as 65.

Key Takeaways

  • Binary is fundamental - Computers use binary (base 2) because electronic circuits easily represent two states (0/1, on/off).
  • Number system conversions are essential - Be able to convert between binary, denary, and hexadecimal systems.
  • Two's complement is standard - It's the method used by computers to represent signed integers, with advantages over sign and magnitude.
  • Overflow occurs when calculations exceed storage capacity (e.g., 255+1=0 in 8-bit).
  • ASCII represents English characters using 7-bit codes (128 characters), while extended ASCII uses 8-bit (256 characters).
  • Unicode supports all languages with code points like U+0041 for 'A'. It's backward compatible with ASCII.
  • BCD (Binary Coded Decimal) represents each decimal digit with 4 bits, used in financial systems and digital displays for accuracy.
  • Binary prefixes (kibi, mebi, gibi) are based on powers of 2 (1,024), while decimal prefixes (kilo, mega, giga) are based on powers of 10 (1,000).
  • The same binary pattern can represent different things (number, character, etc.) depending on context and memory location.
  • Hexadecimal is compact - One hex digit represents 4 binary bits, making it convenient for representing binary data.
  • Character sets are grouped logically - In ASCII, A-Z, a-z, and 0-9 are in consecutive codes, simplifying processing.
  • Real-world applications include web colors (hex), banking (BCD), international software (Unicode), and storage measurements (binary prefixes).

Question Bank

Marking Scheme & Answer
  1. [1 mark] Start with the denary number (203)
  2. [1 mark] Divide by 2, record quotient and remainder: 203÷2=101 remainder 1
  3. [1 mark] Continue dividing quotient by 2 until quotient is 0:
    101÷2=50 R1
    50÷2=25 R0
    25÷2=12 R1
    12÷2=6 R0
    6÷2=3 R0
    3÷2=1 R1
    1÷2=0 R1
  4. [1 mark] Read remainders from bottom to top: 11001011
  5. [1 mark] Result: 203₁₀ = 11001011₂
Marking Scheme & Answer
How two's complement works:
  • [1 mark] To represent a negative number:
    1. Start with positive binary equivalent
    2. Invert all bits (one's complement)
    3. Add 1 to the result
  • [1 mark] Most significant bit indicates sign: 0=positive, 1=negative
  • [1 mark] Range for n bits: -2ⁿ⁻¹ to +2ⁿ⁻¹ - 1
Advantages over sign and magnitude:
  • [1 mark] Only one representation of zero (sign and magnitude has +0 and -0)
  • [1 mark] Simplifies arithmetic operations - addition and subtraction use same circuitry
  • [1 mark] Numbers are in continuous sequence: adding 1 to -1 gives 0, etc.
Marking Scheme & Answer
Carry: 1 1 1 1 1
0 1 1 0 1 1 0 1 (109)
+ 0 0 1 1 1 0 1 1 (59)
1 0 1 0 1 0 0 0 (168)
  • [2 marks] Binary result: 10101000₂
  • [1 mark] No overflow occurs (both positive, result positive, carry out = 1 but sign bits consistent)
  • [1 mark] Convert to denary: 10101000₂ = 128 + 0 + 32 + 0 + 8 + 0 + 0 + 0
  • [1 mark] = 168₁₀
Marking Scheme & Answer
ASCII:
  • 7-bit encoding
  • 128 characters
  • English letters, digits, basic symbols
  • Standard for early computing
Extended ASCII:
  • 8-bit encoding
  • 256 characters
  • Adds graphics, accented characters
  • Backward compatible with ASCII
Unicode:
  • 16/32-bit encoding
  • 65,536+ characters
  • All world languages, emojis
  • Backward compatible with ASCII
Key Comparison:
  • ASCII is subset of extended ASCII, which is subset of Unicode
  • Unicode is universal, while ASCII/extended ASCII are limited to English/Western languages
  • All share same first 128 codes for compatibility
Marking Scheme & Answer
  • [1 mark] BCD (Binary Coded Decimal) is an encoding where each decimal digit (0-9) is represented by 4 binary bits.
  • [2 marks] Application 1: Financial/Banking Systems
    • Justification: BCD represents decimal values exactly without binary rounding errors
    • Critical for accurate monetary calculations (exact cents/pence)
  • [2 marks] Application 2: Digital Displays (calculators, clocks)
    • Justification: Easy conversion to individual digits for display
    • Each BCD digit can directly drive 7-segment displays
Marking Scheme & Answer
(a) To binary:
  • [1 mark] 2 = 0010
  • [1 mark] F = 1111 (F=15)
  • [1 mark] 8 = 1000
  • [1 mark] A = 1010 (A=10)
  • [Result] 2F8A₁₆ = 0010 1111 1000 1010₂
(b) To denary:
  • [1 mark] Place values: 4096, 256, 16, 1
  • [1 mark] Calculation: (2×4096) + (15×256) + (8×16) + (10×1)
  • [1 mark] = 8192 + 3840 + 128 + 10 = 12,170₁₀
Marking Scheme & Answer
Differences:
  • [1 mark] Decimal prefixes (kilo, mega, giga) are based on powers of 10 (10³, 10⁶, 10⁹)
  • [1 mark] Binary prefixes (kibi, mebi, gibi) are based on powers of 2 (2¹⁰, 2²⁰, 2³⁰)
  • [1 mark] Kilobyte (KB) = 1,000 bytes, Kibibyte (KiB) = 1,024 bytes
  • [1 mark] Decimal prefixes used for data transmission rates, binary prefixes for memory/storage
Example calculation:
  • [1 mark] Convert 5,000 bytes to kilobytes and kibibytes:
  • Kilobytes: 5,000 ÷ 1,000 = 5 KB
  • Kibibytes: 5,000 ÷ 1,024 ≈ 4.88 KiB
Marking Scheme & Answer
  • [1 mark] Overflow occurs when the result of an arithmetic operation exceeds the maximum value that can be represented with the given number of bits.
  • [1 mark] In 8-bit binary, maximum unsigned value is 255 (11111111₂).
  • [1 mark] Example: 255 + 1 = 256, which in binary is 100000000 (9 bits).
  • [1 mark] The CPU drops the overflow (9th) bit because it cannot store it, resulting in 00000000 (0). So 255 + 1 = 0 (incorrect due to overflow).
Marking Scheme & Answer
  1. [1 mark] Find positive binary of 47: 47₁₀ = 00101111₂
  2. [1 mark] Invert all bits (one's complement): 00101111 → 11010000
  3. [1 mark] Add 1: 11010000 + 1 = 11010001
  4. [1 mark] Result: -47₁₀ = 11010001₂ in 8-bit two's complement
Check: 11010001 = -128 + 64 + 0 + 16 + 0 + 0 + 0 + 1 = -128 + 81 = -47 ✓
Marking Scheme & Answer
Two interpretations:
  • [1 mark] As a number: 01000001₂ = 65₁₀
  • [1 mark] As a character: ASCII code 65 = 'A'
  • [1 mark] Could also be part of an image (pixel intensity), sound sample, or other data
How computer knows:
  • [1 mark] The computer knows by the context - the memory address where data is stored
  • [1 mark] Different memory locations are designated for different data types (text area, number area, etc.)
  • [Additional] The program knows what type of data to expect at each memory location based on variable declarations