CSEC ICT Essential Knowledge: Computers process and store all information using binary digits (bits) – the fundamental language of computing. Understanding number systems (binary, octal, hexadecimal), binary arithmetic, integer representations, and character encoding (ASCII) is essential for understanding how computers work at their most basic level.
Key Concept: All digital data – whether numbers, text, images, or sound – is ultimately represented and manipulated as sequences of 0s and 1s. Different encoding schemes translate between human-readable information and computer-processable binary data.
Part 1: Number Systems in Computing
The Binary System: Foundation of Computing
Computers use binary because electronic components can reliably represent two states: ON/OFF, HIGH/LOW voltage, or magnetized/not magnetized. These two states are represented as 1 and 0.
A byte (8 bits) representing the binary number 10101100
Binary is a base-2 system. Each digit (bit) represents a power of 2, starting from 2โฐ at the rightmost position.
Binary 1011 = (1ร8) + (0ร4) + (1ร2) + (1ร1) = 8 + 0 + 2 + 1 = 11 in decimal
Binary (Base-2)
Digits: 0, 1
Example: 1101โ = 13โโ
Conversion: Sum of powers of 2
Use: Direct computer processing
Octal (Base-8)
Digits: 0-7
Example: 75โ = 61โโ
Conversion: Sum of powers of 8
Use: Shortening binary (3 bits = 1 octal digit)
Hexadecimal (Base-16)
Digits: 0-9, A-F
Example: 2Fโโ = 47โโ
Conversion: Sum of powers of 16
Use: Shortening binary (4 bits = 1 hex digit), memory addresses
Converting Between Number Systems
Binary to Decimal: Sum the powers of 2 for each ‘1’ bit
Decimal to Binary: Repeated division by 2, collecting remainders
Group binary digits into sets of 4 (from right), convert each group to hex
Binary: 1101 0110
Group 1: 1101 = Dโโ (13 in decimal)
Group 2: 0110 = 6โโ
Result: D6โโ
Memory Aid: For hex digits A-F: A=10, B=11, C=12, D=13, E=14, F=15. Remember “All Boys Can Develop Excellent Focus” or create your own mnemonic!
Part 2: Binary Arithmetic
Binary Addition and Subtraction
Follows simple rules similar to decimal addition but with only two digits:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 0, carry 1
- 1 + 1 + 1 = 1, carry 1
Example: 0110 + 0101 (6 + 5 in decimal)
Result: 1011โ = 11โโ (6 + 5 = 11 โ)
Two primary methods:
- Direct Subtraction: Similar to decimal borrowing
- Using Two’s Complement: More efficient for computers (see below)
1010 – 0110 (10 – 6 in decimal)
Step 1: 0 – 0 = 0
Step 2: Borrow needed: 1 – 1 = 0 (after borrowing)
Step 3: 0 – 1 = 1 (with borrow)
Step 4: 0 – 0 = 0
Result: 0100โ = 4โโ (10 – 6 = 4 โ)
Part 3: Integer Representation in Computers
Representing Positive and Negative Integers
Sign and Magnitude
Concept: Leftmost bit indicates sign (0=positive, 1=negative), remaining bits show magnitude
Example (8-bit): +5 = 00000101, -5 = 10000101
Advantage: Simple to understand
Disadvantage: Two representations of zero (+0 and -0), complex arithmetic
Binary Coded Decimal (BCD)
Concept: Each decimal digit represented by 4 binary bits
Example: 47 = 0100 0111 (4=0100, 7=0111)
Advantage: Accurate decimal representation
Disadvantage: Inefficient storage, complex arithmetic
Two’s Complement
Concept: Most significant bit indicates sign, negative numbers represented as complement+1
Example (8-bit): +5 = 00000101, -5 = 11111011
Advantage: Single zero representation, simple subtraction via addition
Disadvantage: Range asymmetry (one extra negative number)
This is the standard method used by modern computers because it simplifies arithmetic operations.
Creating Two’s Complement (8-bit example):
1. Start with positive number: +5 = 00000101
2. Invert all bits (1’s complement): 11111010
3. Add 1: 11111010 + 1 = 11111011
Result: -5 = 11111011
Range for 8-bit: -128 to +127 (Note: one extra negative number)
Why Two’s Complement? Subtraction becomes addition! To calculate A – B, the computer finds two’s complement of B and adds it to A. This simplifies hardware design as only addition circuits are needed.
Part 4: Character Representation – ASCII
ASCII: The Universal Text Code
ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding standard that represents text in computers. Originally 128 characters, extended ASCII uses 8 bits (256 characters).
Control characters (red) and printable characters (green)
- 0-31: Control characters (non-printable)
- 32-126: Printable characters (letters, digits, punctuation)
- 127: Delete character
- 128-255: Extended ASCII (varies by system)
| Character | ASCII Code (Decimal) | Binary (7-bit) | Hex |
|---|---|---|---|
| ‘A’ (uppercase) | 65 | 100 0001 | 41 |
| ‘a’ (lowercase) | 97 | 110 0001 | 61 |
| ‘0’ (zero) | 48 | 011 0000 | 30 |
| Space | 32 | 010 0000 | 20 |
| New Line | 10 | 000 1010 | 0A |
ASCII’s limitation (only 128/256 characters) led to Unicode, which can represent over 1 million characters covering all writing systems.
- UTF-8: Variable length (1-4 bytes), backward compatible with ASCII
- UTF-16: 2 or 4 bytes per character
- UTF-32: Fixed 4 bytes per character
Most modern systems use UTF-8 as it’s efficient for English text while supporting all languages.
Quiz: Test Your Understanding
To Decimal:
11001101โ = (1ร128) + (1ร64) + (0ร32) + (0ร16) + (1ร8) + (1ร4) + (0ร2) + (1ร1)
= 128 + 64 + 0 + 0 + 8 + 4 + 0 + 1 = 205โโ
To Hexadecimal:
Group into 4-bit groups: 1100 1101
1100โ = Cโโ (12 in decimal)
1101โ = Dโโ (13 in decimal)
Result: CDโโ
Verification: Cโโ = 12ร16 = 192, Dโโ = 13, 192+13=205 โ
Binary Addition:
1 0 1 1 (11 in decimal)
+ 0 1 1 0 (6 in decimal)
———-
1 0 0 0 1
Working:
Column 1 (rightmost): 1 + 0 = 1
Column 2: 1 + 1 = 0, carry 1
Column 3: 0 + 1 + carry 1 = 0, carry 1
Column 4: 1 + 0 + carry 1 = 0, carry 1
Column 5: carry 1 = 1
Result: 10001โ
To decimal: 10001โ = (1ร16) + (0ร8) + (0ร4) + (0ร2) + (1ร1) = 16 + 0 + 0 + 0 + 1 = 17โโ
Verification: 11 + 6 = 17 โ
Two’s Complement Advantages:
1. Single Zero Representation: Sign and magnitude has +0 (00000000) and -0 (10000000), causing confusion and wasted values. Two’s complement has only one zero (00000000).
2. Simpler Arithmetic: Subtraction becomes addition. To compute A – B, the computer:
a. Calculates two’s complement of B
b. Adds it to A
This means only addition circuits are needed, simplifying hardware design.
3. Consistent Arithmetic: The same addition circuit works for both positive and negative numbers.
4. Efficient: No special cases needed for sign handling during addition.
Example: With 8-bit two’s complement, subtracting 5 from 7:
7 = 00000111, -5 = 11111011 (two’s complement of 00000101)
00000111 + 11111011 = 00000010 (with overflow discarded) = 2 โ
ASCII for ‘K’:
Decimal: 75
Binary: 1001011 (7-bit) or 01001011 (8-bit with leading 0)
Hexadecimal: 4B
ASCII for ‘k’:
Decimal: 107
Binary: 1101011 (7-bit) or 01101011 (8-bit with leading 0)
Hexadecimal: 6B
Difference: Lowercase letters are exactly 32 decimal values higher than their uppercase counterparts in ASCII. This corresponds to flipping the 6th bit (from right, starting at 1):
‘K’: 1001011
‘k’: 1101011 (bit 6 changed from 0 to 1)
Pattern: Uppercase A-Z: 65-90, Lowercase a-z: 97-122. The difference is always 32 (2โต).
Steps to find -23 in 8-bit two’s complement:
1. Start with positive 23: 23โโ = 00010111โ
(16 + 4 + 2 + 1 = 23)
2. Find one’s complement (invert all bits): 11101000
3. Add 1 to get two’s complement:
11101000 + 1 = 11101001
Result: -23โโ = 11101001โ in 8-bit two’s complement
Verification: Convert back to decimal to check:
Since MSB is 1, it’s negative. To find magnitude:
a. Invert bits: 00010110
b. Add 1: 00010111 = 23
Confirmed: -23 โ
Note: In two’s complement, negative numbers have their most significant bit (leftmost) set to 1.
๐ฏ Key Concepts Summary
- Binary (Base-2): Computers’ native language using only 0s and 1s
- Octal (Base-8) & Hexadecimal (Base-16): Shorthand for binary, easier for humans
- Binary Addition: 1+1=0 with carry 1; similar to decimal but simpler
- Integer Representations:
- Sign and Magnitude: Simple but has ยฑ0
- BCD: Accurate decimal but inefficient
- Two’s Complement: Industry standard, simplifies arithmetic
- ASCII: 7-bit character encoding (128 chars), extended to 8-bit (256 chars)
- Character Patterns: Uppercase A=65, lowercase a=97, digit 0=48
- Unicode: Modern standard supporting all languages, UTF-8 is common
- Bit: Binary digit (0 or 1)
- Byte: 8 bits (can represent 256 values)
- Two’s Complement Trick: To quickly find negative: invert bits, add 1
CSEC Exam Strategy: When answering data representation questions: (1) Clearly show conversion steps, (2) Use correct notation (subscript for base), (3) For two’s complement, demonstrate the invert-and-add-1 process, (4) Remember ASCII patterns (A=65, a=97, 0=48), (5) Practice binary arithmetic with carries. Always verify your answer by converting back to decimal.
