NUMBER SYSTEM AND CONVERSIONS - openhorizonrobotics/ece-1 GitHub Wiki
Number System is a method of representing numbers on the number line with the help of a set of Symbols and rules. These symbols range from 0-9 and are termed as digits. Letβs learn about the number system in detail, including its types, and conversion.
The base or radix determines how many unique symbols (or digits) are available and how place values increase as you move to the left.
Types of Number Systems
Based on the base value and the number of allowed digits, number systems are of many types.
The four common types of Number Systems are:
-
Decimal Number System
- Base: 10
- Digits Used: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
-
Binary Number System
- Base: 2
- Digits Used: {0, 1}
-
Octal Number System
- Base: 8
- Digits Used: {0, 1, 2, 3, 4, 5, 6, 7}
-
Hexadecimal Number System
- Base: 16
- Digits Used: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
A number N in base or radix b can be written as:
(N)b = dn-1 dn-2 -- -- -- -- d1 d0 . d-1 d-2 -- -- -- -- d-m
In the above, ( d_{n-1} ) to ( d_0 ) is the integer part, then follows a radix point, and then ( d_{-1} ) to ( d_{-m} ) is the fractional part.
- ( d_{n-1} ): Most Significant Bit (MSB)
- ( d_{-m} ): Least Significant Bit (LSB)
Decimal Number System
The number system with base value 10 is termed as the Decimal Number System. It uses 10 digits, i.e., 0-9, for the creation of numbers.
Here, each digit in the number is at a specific place, with the place value being a product of different powers of 10. The place values are termed from right to left as:
- First place: Units ((10^0))
- Second place: Tens ((10^1))
- Third place: Hundreds ((10^2))
- Fourth place: Thousands ((10^3)), and so on.
Example: 10285
The place values are as follows:
[
(1 \times 10^4) + (0 \times 10^3) + (2 \times 10^2) + (8 \times 10^1) + (5 \times 10^0)
]
[
1 \times 10000 + 0 \times 1000 + 2 \times 100 + 8 \times 10 + 5 \times 1
]
[
10000 + 0 + 200 + 80 + 5 = 10285
]
Binary Number System
The number system with base value 2 is termed as the Binary Number System. It uses 2 digits, i.e., 0 and 1, for the creation of numbers. Numbers formed using these two digits are called Binary Numbers.
The Binary Number System is highly useful in electronic devices and computer systems because it represents two states: ON (1) and OFF (0).
Decimal Numbers Represented in Binary:
- 0: (0)
- 1: (1)
- 2: (10)
- 3: (11)
- 4: (100)
- 5: (101)
- 6: (110)
- 7: (111)
- 8: (1000)
- 9: (1001)
Examples:
- (14_{10}) can be written as (1110_2)
- (19_{10}) can be written as (10011_2)
- (50_{10}) can be written as (110010_2)
Octal Number System
The Octal Number System is a number system with base value 8. It uses 8 digits, i.e., 0-7, for the creation of numbers.
Octal Numbers can be converted to Decimal by multiplying each digit with its place value and then adding the results. The place values are (8^0), (8^1), (8^2), and so on.
Example:
- (135_{10}) can be written as (207_8)
- (215_{10}) can be written as (327_8)
Note: Octal Numbers are often used for representing UTF-8 characters.
Hexadecimal Number System
The number system with base value 16 is termed as the Hexadecimal Number System. It uses 16 digits for creating numbers:
- Digits 0-9 are the same as in the Decimal Number System.
- Digits 10-15 are represented as A-F:
- (10 β A)
- (11 β B)
- (12 β C)
- (13 β D)
- (14 β E)
- (15 β F)
Examples:
- (255_{10}) can be written as (FF_{16})
- (1096_{10}) can be written as (448_{16})
- (4090_{10}) can be written as (FFA_{16})
Note: Hexadecimal Numbers are useful for representing memory addresses in computer systems.
Number system Conversion methods:
Decimal to Binary Conversion
To convert a decimal number to binary, divide the decimal number by 2 repeatedly and record the remainder. The binary representation is obtained by writing the remainders in reverse order (from bottom to top).
Example: Convert (25)ββ to Binary
Let us create a table based on this question:
Operation | Output | Remainder |
---|---|---|
25 Γ· 2 | 12 | 1 (MSB) |
12 Γ· 2 | 6 | 0 |
6 Γ· 2 | 3 | 0 |
3 Γ· 2 | 1 | 1 |
1 Γ· 2 | 0 | 1 (LSB) |
Binary Representation
From the table, write the remainders in reverse order:
(25)ββ = (11001)β
Binary to Decimal Conversion
To convert a binary number to a decimal number, use the multiplication method. Each digit of the binary number is multiplied by the base (2) raised to a power, starting from the most significant bit (MSB) to the least significant bit (LSB), with the power reducing from left to right.
Example: Convert (1101)β to Decimal
Given a binary number (1101)β.
Multiply each digit from MSB to LSB by 2 raised to the respective power:
1 Γ 2Β³ + 1 Γ 2Β² + 0 Γ 2ΒΉ + 1 Γ 2β°
= 8 + 4 + 0 + 1 = 13
Decimal Representation
(1101)β = (13)ββ
If you wanna study in depth about more number system conversions, you can refer this link.