CSI 02 Tim
CSI 02 Tim
NUMBERING
SYSTEMS
1. Introduction
3. Conversion
2
OBJECTIVES
3
CONTENT
1. Introduction
3. Conversion
4
INTRODUCTION
• A number system (or numeral system) defines how a number can be represented using
distinct symbols.
• A number can be represented differently in different systems.
o For example, the two numbers (26)!" and (46)# both refer to the same quantity, (38)!$ , but
their representations are different.
Number System
1. Introduction
3. Conversion
6
NUMBER SYSTEMS: Introduction
8
BINARY SYSTEM (base 2)
Why hexadecimal?:
o Easy conversion between binary and hexadecimal numbers
o Fewer required symbols to represent a large value in hexadecimal
• The second system that was devised to show the equivalent of the binary system
outside the computer is the octal system.
• The base 𝑏 = 8, and we use eight symbols to represent a number.
• The set of symbols is 𝑆 = {0, 1, 2, 3, 4, 5, 6, 7}. The symbols in this system are often
referred to as octal digits.
12
CONTENT
1. Introduction
3. Conversion
13
INTRODUCTION
14
ANY BASE ➾ DECIMAL
15
ANY BASE ➾ DECIMAL (examples)
Example 2.5. Convert the hexadecimal number (1A. 23)"# to decimal : (1A. 23)"# =
26.137 16
ANY BASE ➾ DECIMAL: PRACTICE
101011.1101
Binary à decimal
1011.011
1254.765
Octal à decimal 452.694
125.13
1A.3GF
Hex à decimal
35.E02
17
ANY BASE ➾ DECIMAL: PRACTICE
101011.1101 43.8125
Binary à decimal
1011.011 11.375
1254.765 684.978515625
Octal à decimal 452.694 Error
125.13 85.171875
1A.3GF Error
Hex à decimal
35.E02 53.87548828125
18
DECIMAL ➾ ANY BASE
We can convert a decimal number to its equivalent in any base. We need two procedures,
one for the integral part and one for the fractional part.
27.25
Decimal à Binary
35
Decimal à Octal 27
35.125
27
Decimal à Hexa
25
21
DECIMAL ➾ ANY BASE : PRACTICE
27.25
Decimal à Binary
35
27
Decimal à Hexa
35.125
22
DECIMAL ➾ ANY BASE : PRACTICE
27 11011
Decimal à Binary
35 100011
Decimal à Octal 27 33
35 43
27 1B
Decimal à Hexa
25 19
23
NUMBER OF DIGITS
In a positional number system with base 𝑏, the number of digits of an integer is:
𝐾 = log . 𝑁 in which: 𝑏 is the base
x is ceiling of x
𝑁 is the decimal value of the integer
Eg: find the required number of bits needed to represent 234 in all four systems
Ø in decimal: 𝐾 = log*, 234 = 2.36 = 3
Ø in binary: 𝐾 = log + 234 = 7.87 = 8
Ø in octal: 𝐾 = log 1 234 = 2.62 = 3
Ø in hexa: 𝐾 = log*2 234 = 1.96 = 2
24
BINARY – HEXADECIMAL CONVERSION
Example 2.4
What is the binary equivalent of 24C%& ?
Solution
Each hexadecimal digit is converted to 4-bit patterns: 2 → 0010, 4 → 0100, and C → 1100.
The result is 001001001100#
25
BINARY – OCTAL CONVERSION
Example 2.5
What is the binary equivalent of (24)$ ?
Solution
Write each octal digit as its equivalent bit pattern to get (010100)#
26
OCTAL – HEXADECIMAL CONVERSION
27
NUMBER OF DIGITS
log 𝑏* log 𝑏*
𝑥 ≥ 𝐾× OR 𝑥 = 𝐾×
log 𝑏+ log 𝑏+
Example: Find the minimum number of binary digits required to store decimal
integers with a maximum of six digits.
Solution:
• We have: 𝐾 = 6 , 𝑏* = 10, 𝑏+ = 2
• Then 𝑥 = 𝐾× log 𝑏* = 6× log 10 = 6× 1
= 20
log 𝑏+ log 2 0.30103
• The largest 6-digit decimal number is 999999 and the largest 20-bit binary
number is 1048575.
• Note that the largest number that can be represented by a 19-bit number is
524287, which is smaller than 999999. We definitely need 20 bits.
29
PRACTICE
30
2. Convert the following decimals to binary numbers, then octal numbers, then
hexadecimals using only your calculator.
a) 45.625
b) 2022
c) 35.125
31
3. Without converting, find the minimum number of digits needed in the
destination system for each of the following cases:
a) 7-bit binary number converted to decimal
b) 3-digit decimal number converted to binary
c) 4-digit decimal converted to hexadecimal
d) 8-digit octal number converted to decimal
e) 6-digit decimal converted to octal
32