0% found this document useful (0 votes)
11 views32 pages

CSI 02 Tim

The document provides an overview of various numbering systems, including decimal, binary, octal, and hexadecimal, explaining their bases, symbols, and conversion methods. It outlines the objectives for understanding these systems and includes examples and practice problems for converting between them. Additionally, it discusses the number of digits required to represent values in different systems.

Uploaded by

lamm6897
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views32 pages

CSI 02 Tim

The document provides an overview of various numbering systems, including decimal, binary, octal, and hexadecimal, explaining their bases, symbols, and conversion methods. It outlines the objectives for understanding these systems and includes examples and practice problems for converting between them. Additionally, it discusses the number of digits required to represent values in different systems.

Uploaded by

lamm6897
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

CSI104 Week 02

NUMBERING
SYSTEMS

Tam Nguyen (FU HL- SE)


Jan 2024
CONTENT

1. Introduction

2. Positional Number Systems

3. Conversion

2
OBJECTIVES

After studying this chapter, the student should be able to:


• Understand the concept of number systems.
• Distinguish between non-positional and positional number systems.
• Describe the decimal system (base 10).
• Describe the binary system (base 2).
• Describe the hexadecimal system (base 16).
• Describe the octal system (base 8).
• Convert a number in binary, octal, or hexadecimal to a number in the decimal system.
• Convert a number in the decimal system to a number in binary, octal, or hexadecimal.
• Find the number of digits needed in each system to represent a particular value.

3
CONTENT

1. Introduction

2. Positional Number Systems

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

Decimal Binary Octal Hexadecimal


Number Number Number Number

Base 10 Base 2 Base 8 Base 16


[0 – 9] [0 – 1] [0 – 7] [0 – 9,A – F]

Figure 2.1. Types of number system 5


CONTENT

1. Introduction

2. Positional Number Systems

3. Conversion

6
NUMBER SYSTEMS: Introduction

• In a positional number system, the position a symbol occupies in the number


determines the value it represents.
• In this system, a number represented as:
± (𝑆()* . . . 𝑆+ 𝑆* 𝑆,. 𝑆)*𝑆)+ . . . 𝑆)- ).
has the value of:
± 𝑆()*×𝑏 ()*+ . . . +𝑆*×𝑏* + 𝑆,×𝑏 ,
+𝑆)*×𝑏 )* + 𝑆)+×𝑏 )+ +. . . + 𝑆)- ×𝑏 )-

in which: 𝑆 is the set of symbols


𝑏 is the base (or radix)
𝑆! and 𝑆" are symbols in the whole and fraction parts of the number
7
DECIMAL SYSTEM (base 10)

• The base 𝑏 = 10, and we use ten symbols to represent a number

• The set of symbols is 𝑆 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. As we know, the symbols in


this system are often referred to as decimal digits or just digits.

• In the decimal system, a number is written as:

± (𝑆()* . . . 𝑆+ 𝑆* 𝑆,. 𝑆)*𝑆)+ . . . 𝑆)- )*,

8
BINARY SYSTEM (base 2)

• The base 𝑏 = 2; and we use 2 symbols to represent a number, 𝑆 = {0, 1}.


• The symbols in this system are often referred to as binary digits or bits.
• Data and programs are stored in the computer using binary patterns, a string of
bits.

Example 2.1. (101.11)! in binary = 5.75 in decimal


9
HEXADECIMAL SYSTEM (base 16)

Why hexadecimal?:
o Easy conversion between binary and hexadecimal numbers
o Fewer required symbols to represent a large value in hexadecimal

• The base 𝑏 = 16, and we use 16 symbols to represent a number.


• The set of symbols is 𝑆 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 𝐴, 𝐵, 𝐶, 𝐷, 𝐸, 𝐹}.

Example 2.2. the number (2𝐴𝐸)"# in hexadecimal = 686 in decimal 10


OCTAL SYSTEM (base 8)

• 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.

Example 2.3. the number (1256)# in octal = 686 in decimal


11
SUMMARY OF THE FOUR NUMBER SYSTEMS

System Base Symbols Examples


Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 2345.56
Binary 2 0, 1 (1001.11)#
Octal 8 0, 1, 2, 3, 4, 5, 6, 7, 8 (156.23)$
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (𝐴2𝐶. 𝐴1)%&

Table 2.1. Summary of the four positional number systems

12
CONTENT

1. Introduction

2. Positional Number Systems

3. Conversion

13
INTRODUCTION

• We need to know how to convert a number in


one system to the equivalent number in
another system. Since the decimal system is
more familiar than the other systems.
• Any base to decimal conversion
• Decimal to any base conversion
• Binary to hexadecimal or octal conversion
and vice versa

Figure 2.2. Types of number system

14
ANY BASE ➾ DECIMAL

Figure 2.2. Converting other bases to decimal

15
ANY BASE ➾ DECIMAL (examples)

Example 2.4. Convert the binary number (110.11)! to decimal: (110.11)! =


6.75

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.

Convert 35 in decimal to binary

Convert 126 in decimal to Octal

Figure 2.3. Algorithm to convert the integral part 19


DECIMAL ➾ ANY BASE (cont.)

Convert decimal number 0.625 to binary

Convert 0.634 to octal using a maximum of four digits

Figure 2.4. Algorithm to convert the fractional part 20


DECIMAL ➾ ANY BASE : PRACTICE

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

Figure 2.5. Binary to hexadecimal & hexadecimal to binary

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

Figure 2.6. Binary to octal & octal to binary

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

Figure 2.7. Octal to hexadecimal and hexadecimal to octal conversion

27
NUMBER OF DIGITS

• Using 𝐾 digits in base 𝑏* system, the maximum number we can represent in


the source system is: 𝑏*( − 1
• The maximum number we can represent in the destination system is: 𝑏+3 − 1
• Thus, we need: 𝑏+3 − 1 ≥ 𝑏*( − 1

log 𝑏* log 𝑏*
𝑥 ≥ 𝐾× OR 𝑥 = 𝐾×
log 𝑏+ log 𝑏+

in which: 𝐾 is the number of digits in the source number system


𝑏! is the source system
𝑏" is the destination system
28
NUMBER OF DIGITS

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

1. Convert the following numbers to decimal without using a calculator, showing


your work:
a) (01101)2
b) (1111001)2
c) (011110.01)2
d) (100101.101)2
e) (3DF)16
f) (1977)8

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

You might also like