2. Number System
2.1 Number System Basics
Welcome to the world of number systems! In this module, we'll explore how computers represent and work with numbers, and how we can convert between different number systems.
Learning Objectives
- Understand different types of number systems used in computing
- Learn about binary, decimal, octal, and hexadecimal systems
- Understand the importance of number systems in computing
2.1.1 What is a Number System?
Definition
A number system is a way to represent numbers using digits or other symbols in a consistent manner. The value of each digit in a number can be determined by its position in the number, its digit value, and the base of the number system.
Types of Number Systems
There are several types of number systems, but in computing, we primarily work with four:
| Number System | Base | Digits Used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | 10102 |
| Decimal | 10 | 0-9 | 1010 |
| Octal | 8 | 0-7 | 128 |
| Hexadecimal | 16 | 0-9, A-F | A116 |
2.1.2 Importance in Computing
Number systems are fundamental to how computers work:
Binary in Computers
Computers use the binary system (base-2) because digital electronics have two stable states: on (1) and off (0). All data in computers is ultimately represented in binary form.
Memory Addressing
Memory locations in computers are addressed using binary numbers. Hexadecimal is often used as a more human-readable representation of these binary addresses.
Color Representation
Colors in web design are often represented in hexadecimal format (e.g., #FF5733) which is more compact than binary and easier to read than decimal.
2.1.3 Basic Conversion Concepts
Understanding how to convert between different number systems is a key skill in computer science. Here's a quick overview:
Positional Notation
In any number system, the position of each digit represents a power of the base. For example, in the decimal number 34510:
3 × 102 + 4 × 101 + 5 × 100 = 300 + 40 + 5 = 34510
Common Conversion Methods
- Binary to Decimal: Multiply each bit by 2position and add
- Decimal to Binary: Divide by 2 and record remainders
- Binary to Hexadecimal: Group binary digits into sets of four
- Hexadecimal to Binary: Convert each hex digit to 4 binary bits
Real World Example
When you see a color code like #FF5733 in web design, it's actually three pairs of hexadecimal numbers representing red (FF), green (57), and blue (33) components. Each pair can be converted to binary for the computer to understand.
Knowledge Check
Test your understanding of number systems with these multiple-choice questions.