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.
Decimal (Denary)
Base 10 system using digits 0-9
Binary
Base 2 system using digits 0 and 1
Hexadecimal
Base 16 system using digits 0-9 and A-F
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×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³ | 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
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 |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
Hex to Binary Conversion
Convert hex number 45A to binary:
Binary to Hex Conversion
Convert binary 10110101 to hex:
Hex to Denary Conversion
Convert hex 45A to denary:
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:
- Convert 156₁₀ to binary
- Convert 10101101₂ to denary
- Convert 3F₂₁₆ to binary
- Convert 11010111₂ to hexadecimal
- Convert 89₁₀ to hexadecimal
Hint: Use the division method for denary to binary, and remember that each hex digit equals 4 binary bits.
Solution:
- 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)
- 10101101₂ = 128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173₁₀
- 3F₂₁₆ = 3=0011, F=1111, 2=0010 → 0011 1111 0010₂
- 11010111₂ = D7₁₆ (1101=D, 0111=7)
- 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:
- How can you tell if a binary number is odd just by looking at it?
- What is the largest decimal number you can represent with 8 bits?
- If a binary number ends with 0, is it even or odd?
- How many different values can be represented with 4 bits?
- What binary pattern represents the decimal number 0 in 8-bit representation?
Solution:
- A binary number is odd if its rightmost digit (least significant bit) is 1.
- With 8 bits, the largest decimal number is 255 (2⁸ - 1 = 256 - 1 = 255).
- 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 bits can represent 16 different values (2⁴ = 16), from 0 to 15.
- 0 in 8-bit binary is 00000000.
Check Your Understanding: Number Systems
1. What is the base of the binary number system and why is it used in computers? [2 marks]
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.
2. Convert the hexadecimal number A3F to binary. [3 marks]
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₂
3. Explain why hexadecimal is often used in computing instead of binary. [2 marks]
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.
4. Convert 101101₂ to denary. Show your working. [3 marks]
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₁₀
5. What is a nibble and how does it relate to hexadecimal? [2 marks]
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:
58₁₀ = 00111010₂
Now add them:
+ 0 0 1 1 1 0 1 0 (58)
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:
11₁₀ = 1011₂
Subtract (with borrowing):
- 1 0 1 1 (11)
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
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
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:
Example: Represent -28 in 8-bit two's complement
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
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:
- Add: 1011₂ + 1101₂
- Subtract: 1100₂ - 1011₂ (use direct method)
- Subtract using two's complement: 75₁₀ - 42₁₀
- Find two's complement representation of -19 in 8-bit
- What happens when you add 11111111₂ + 00000001₂? Does overflow occur?
Solution:
- 1011₂ + 1101₂ = 11000₂ (Check: 11+13=24, 11000₂=24)
- 1100₂ - 1011₂ = 0001₂ (12-11=1)
- 75-42=33. 75=01001011, 42=00101010, two's complement of 42=11010110, add: 01001011+11010110=100100001, ignore overflow: 00100001=33
- +19=00010011, invert: 11101100, add 1: 11101101 = -19
- 11111111₂ + 00000001₂ = 100000000₂ (9 bits). Yes, overflow occurs. In 8-bit, result would be 00000000 (0).
Check Your Understanding: Binary Arithmetic
1. What is overflow in binary arithmetic and when does it occur? [3 marks]
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.
2. Explain the advantage of two's complement representation over sign and magnitude. [3 marks]
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).
3. Convert the two's complement binary number 10110001 to denary. [3 marks]
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
4. Perform binary addition: 01101001 + 00110110. Does overflow occur? [4 marks]
Answer
+ 0 0 1 1 0 1 1 0 (54)
- [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.
5. What is the range of numbers that can be represented in 8-bit two's complement? [2 marks]
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
00000101 (5)
00000000 (0)
00000011 (3)
Method 2 (packed): Two digits per byte
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
Binary to decimal conversion
ASCII code 65 = 'A'
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 |
|---|---|---|---|
| kilo | K | 10³ | 1,000 |
| mega | M | 10⁶ | 1,000,000 |
| giga | G | 10⁹ | 1,000,000,000 |
| tera | T | 10¹² | 1,000,000,000,000 |
Binary Prefixes (IEC)
Based on powers of 2, used for memory/storage
| Prefix | Symbol | Factor | Bytes |
|---|---|---|---|
| kibi | Ki | 2¹⁰ | 1,024 |
| mebi | Mi | 2²⁰ | 1,048,576 |
| gibi | Gi | 2³⁰ | 1,073,741,824 |
| tebi | Ti | 2⁴⁰ | 1,099,511,627,776 |
Conversion Examples
Convert 34,560 bytes to kibibytes:
How many 2.4 MiB files fit on 4 GiB USB?
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:
- What is the ASCII code for 'Z' in binary, decimal, and hexadecimal?
- How many characters can be represented using extended ASCII (8-bit)?
- Convert 16,384 bytes to kibibytes (KiB).
- What is the Unicode code point for the letter 'B'?
- Why is BCD used in financial systems instead of regular binary?
- What is the difference between a kilobyte (KB) and a kibibyte (KiB)?
Solution:
- 'Z' = ASCII 90 = 01011010₂ = 5A₁₆
- Extended ASCII (8-bit) can represent 256 characters (2⁸ = 256).
- 16,384 bytes ÷ 1,024 = 16 KiB (since 16,384 = 2¹⁴ and 1,024 = 2¹⁰, so 2¹⁴ ÷ 2¹⁰ = 2⁴ = 16)
- 'B' = U+0042 (Unicode code point in hexadecimal).
- BCD is used in financial systems because it represents decimal digits exactly without binary rounding errors, crucial for accurate monetary calculations.
- Kilobyte (KB) = 1,000 bytes (decimal prefix), Kibibyte (KiB) = 1,024 bytes (binary prefix).
Check Your Understanding: Character Representation
1. Compare ASCII and Unicode, listing two similarities and two differences. [4 marks]
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
2. What is BCD and why is it used in calculators and digital clocks? [3 marks]
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.
3. Convert 2.5 GiB to mebibytes (MiB). Show your working. [3 marks]
Answer
- [1 mark] 1 GiB = 1,024 MiB
- [1 mark] 2.5 GiB = 2.5 × 1,024 MiB
- [1 mark] = 2,560 MiB
4. What is a Unicode code point and how is it represented? Give an example. [3 marks]
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).
5. How does a computer know whether binary data 01000001 represents the number 65 or the letter 'A'? [2 marks]
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
1. Describe the process of converting a denary number to binary using the division-by-2 method. Use 203 as an example. [5 marks]
Marking Scheme & Answer
- [1 mark] Start with the denary number (203)
- [1 mark] Divide by 2, record quotient and remainder: 203÷2=101 remainder 1
- [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 - [1 mark] Read remainders from bottom to top: 11001011
- [1 mark] Result: 203₁₀ = 11001011₂
2. Explain how two's complement representation works and why it is preferred over sign and magnitude. [6 marks]
Marking Scheme & Answer
How two's complement works:
- [1 mark] To represent a negative number:
- Start with positive binary equivalent
- Invert all bits (one's complement)
- 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.
3. Perform binary addition: 01101101 + 00111011. Check for overflow and convert result to denary. [5 marks]
Marking Scheme & Answer
+ 0 0 1 1 1 0 1 1 (59)
- [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₁₀
4. Compare and contrast ASCII, extended ASCII, and Unicode. [6 marks]
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
5. What is BCD and describe two real-world applications with justification. [5 marks]
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
6. Convert the hexadecimal number 2F8A to: (a) binary, (b) denary. Show your working. [6 marks]
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₁₀
7. Explain the difference between binary prefixes (kibi, mebi) and decimal prefixes (kilo, mega). Give an example calculation. [5 marks]
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
8. Describe how overflow can occur in 8-bit binary addition and what happens when it does. [4 marks]
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).
9. Represent -47 in 8-bit two's complement form. Show all steps. [4 marks]
Marking Scheme & Answer
- [1 mark] Find positive binary of 47: 47₁₀ = 00101111₂
- [1 mark] Invert all bits (one's complement): 00101111 → 11010000
- [1 mark] Add 1: 11010000 + 1 = 11010001
- [1 mark] Result: -47₁₀ = 11010001₂ in 8-bit two's complement
10. A computer retrieves binary data 01000001 from memory. Explain two different interpretations of this data and how the computer knows which is correct. [5 marks]
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