1. Number System Conversions
Computers operate in the binary system (base-2). Students must master conversions between Binary, Octal (base-8), Decimal (base-10), and Hexadecimal (base-16).
2. Signed Integer Representation
To represent negative numbers in binary, three methods are taught:
- Signed Magnitude: The Most Significant Bit (MSB) acts as the sign bit (0 for positive, 1 for negative). The remaining bits show the absolute magnitude (value).
Example (8-bit): +5 is00000101, -5 is10000101. - One's Complement: Invert all bits of the positive representation (0s become 1s, 1s become 0s).
Example (8-bit): +5 is00000101, -5 is11111010. - Two's Complement (Standard): Invert all bits of the positive representation (1's complement) and add 1.
Example (8-bit): +5 is00000101. One's complement is11111010. Adding 1 gives11111011(which is -5 in 2's complement).
Why 2's complement is preferred:
- It has a single representation for zero (unlike Signed Magnitude which has +0 and -0).
- Arithmetic subtraction operations can be performed using addition circuits (e.g.,
A - B = A + (-B)), simplifying processor design.
3. Character Representation
- ASCII: American Standard Code for Information Interchange. It uses a 7-bit binary code (representing 128 characters) or 8-bit extended ASCII (256 characters). It only represents basic English letters, digits, and control symbols.
- Unicode: A global character set that supports almost all written languages (including Sinhala, Tamil, Japanese). It uses variable-length encoding (like UTF-8, UTF-16) to represent millions of unique symbols, preventing character encoding conflicts.