Week 7 Number System New2021

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Topic: Number System

Chapter 2

1-1
Learning outcomes
At the end of the lesson, student should be able:
• To explain how data is represented in computer.
• To identify the coding system used in data processing
• To differentiate the encoding system
• To understand the concept of number system : decimal and binary
• To understand how is an information in binary, hexadecimal, octal,
and BCD form

1-2
Learning outcomes
• To apply the concept of number system conversion from:
1. Decimal to Binary conversion 8. Octal to Decimal conversion
2. Binary to Decimal conversion 9. Binary to Octal conversion
3. Decimal to Hexadecimal conversion 10. Octal to Binary conversion
4. Hexadecimal to Decimal conversion 11. Decimal to BCD conversion
5. Binary to Hexadecimal conversion 12. BCD to Decimal conversion
6. Hexadecimal to Binary conversion 13. Binary to BCD conversion
7. Decimal to Octal conversion 14. BCD to Binary conversion

1-3
Data Representation
How does a computer represent data?
By using two unique binary digits 1 and 0 to represent the
two states on and off.

computer
recognizes only
two discrete
electrical states
(on and off)

1-4
Data Representation
Bit Byte
A binary digit (1 or 0). A group of 8 bits
(ex:11010011).
The smallest unit of data. Represents a character
Represents an electrical such as a digit, a letter, a
state (on or off). punctuation mark or any
▪ Bit 1 represents On. symbol in computer
▪ Bit 0 represents Off.

1-5
Converting Process
Step 1. Step 2.
The user An electronic signal
presses the for the capital letter D
capital letter is sent to the system
D on the unit.
keyboard.

Step 4. Step 3.
After processing, the binary The signal for the capital letter D is
code for the capital letter D is converted to its binary code
converted to an image, and (01000100) and is stored in memory
displayed on the monitor. for processing.

1-6
Encoding Scheme
ASCII EBCDIC UNICODE
Use 7 bits to represent Use 8 bits to represent used 16 bits to
a character a character represent a character
Can represent 128 Can represent 256 capable to represent
characters characters more than 65000
(27 = 128) (28 = 256)
characters
primarily used on PC primarily used on Implemented in
and server mainframe and several OS (Windows,
midrange servers Mac OS, Linux)

1-7
Number System & Representation Concepts
• What is a number system?
• A set of numerals for representing numbers

1. Binary numbers ( base 2)


2. Decimal numbers (base 10)
3. Hexadecimal numbers (base 16)
4. Octal numbers (base 8)
5. BCD code (represent a 4-bit BCD code)

1-8
Number System & Representation Concepts :
Decimal
• Decimal numbers
• Familiar number use in everyday life
• Consists of number 0 – 9
• Decimal digits are joined together to form longer decimal
numbers
• Also know as base 10 numbering system
• Example:
1 , 2, 3,4, 5, 6, 7, 8, 9, 10, 11, 14,…etc.

1-9
Number System & Representation Concepts :
Decimal
• How to represent 745 in decimal numbers ?

10 2 101 100

745
7 x 100 4 x 10 5x1

= 700 + 40 + 5

1-10
Number System & Representation Concept:
Binary
• Binary numbers Binary digit
• Computer uses the binary digit (bit) 0 and 1
• Bits 0 and 1 are joined together to form binary
numbers. 110
• Binary number represents numeric values
using two symbols 0 and 1
Binary number

1-11
Number System & Representation Concepts :
Binary

• Comparison between decimal


numbers and binary numbers

1-12
(1) Decimal to Binary Conversion
Example :
Convert the number 22 to
the binary number system

Solution :
Desired base is 2, so we repeatedly
divide the given decimal number by 2

1-13
(2) Binary to Decimal Conversion
• In binary number, the column weights (again from right to left)
are as follows:

23 22 21 20

8 4 2 1

1-14
(2) Binary to Decimal Conversion
Example :
Convert the binary number 10111002to decimal number
Solution :

26 25 24 23 22 21 20
1 0 1 1 1 0 0
64 x 1 32 x 0 16 x 1 8 x 1 4 x 1 2 x 0 1 x 0
64 + 0 + 16 + 8 + 4 + 0 + 0 = 92

1-15
Number System & Representation Concepts :
Hexademical

• Hexadecimal numbers
• Uses 16 symbols :
0 , 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
Example: 9B4

1-16
Number System & Representation Concepts :
Hexademical

1-17
(3) Decimal to Hexadecimal Conversion
Example :
Convert the decimal number 42310 to hexadecimal number
Solution :
Desired based is 16, divide
repeatedly the given decimal by 16.
10 in hexadecimal =A
Hence, 42310 = 1A716

1-18
(4) Hexadecimal to Decimal Conversion
• In hexadecimal number, the column weights (again from right to
left) are as follows:

163 162 161 160

4096 256 16 1

1-19
(4) Hexadecimal to Decimal Conversion
Example 1:
Convert 2AF16 to decimal number
Solution 1:
A=10, F=15
Therefore, 2AF16 = 68710

162 161 160


2 A F
2 x 256 10 x 16 15 x 1
512 + 160 + 15 = 687
1-20
(5) Binary to Hexadecimal Conversion
Example :
Convert the binary number 101101110102 to hexadecimal
number.
Solution:
Each hex digit is replaced by 4-bit binary number.

101 1011 1010

1-21
(5) Binary to Hexadecimal Conversion
23 22 21 20 23 22 21 20 23 22 21 20
0 1 0 1 1 0 1 1 1 0 1 0
8x0 4x1 2x0 1x1 8x1 4x0 2x1 1x1 8x1 4x0 2x1 1x0

0+ 4 + 0 + 1 = 5 8 + 0 + 2 + 1= 8 + 0 + 2 + 0 =10
11
5 B A
101101110102 = 5BA16

1-22
(6)Hexadecimal to Binary Conversion
Example :
Convert the hexadecimal number AF716 to binary number
Solution :
Step 1. Change the hexadecimal number to Decimal number.
Step 2. Start exchange from decimal to binary.
Therefore, AF716 = 1010 1111 01112

A F 7
10 15 7
23 22 21 20 23 22 21 20 23 22 21 20
1 0 1 0 1 1 1 1 0 1 1 1
1-23
Number System & Representation :
Octal Octal 3- bit Decimal
digits Binary numbers
• Octal number number
• Base 8 system 0 000 0
• Uses 8 symbol : 1 001 1
0,1,2,3,4,5,6,7 2 010 2
3 011 3
Example : 3568 4 100 4
• Octal digit can be represented 5 101 5
by a 3-bit binary number 6 110 6
7 111 7
1-24
(7) Decimal to Octal Conversion

Example:
Convert the decimal number 26610
to octal number.

Solution:
Desired base is 8, therefore we divide
decimal number repeatedly by 8.
Therefore, 26610 = 4128

1-25
(8) Octal to Decimal Conversion
• In Octal number, the column weights (again from right
to left) are as follows:

82 81 80
64 8 1

1-26
(8) Octal to Decimal Conversion
Example :
Convert the octal number 3728 to a decimal number
Solution :
82 81 80
64 x 3 8x7 1x2
192 + 56 + 2 = 250

Therefore, 3728 = 25010

1-27
(9) Binary to Octal Conversion
Example :
Convert binary number 100 111 010 to an octal number.

Solution : Taking groups of 3 bits, starting from right most and replacing it with an
octal digit.
100111010 = 472 100 111 010
2 8

100 111 010


22 21 20 22 21 20 22 21 20
4x1 2x0 1x0 4x1 2x1 1x1 4x0 2x1 0x1
4 + 0 +0 = 4 4 + 2 +1 = 7 0 + 2 +0 = 2
1-28
(10) Octal to Binary Conversion
Example :
Conversion from octal to binary numbers , given 2758
Solution :

2 7 5
22 21 20 22 21 20 22 21 20
0 1 0 1 1 1 1 0 1
2758 = 0101111012

1-29
Number System & Representation :
Binary Code Decimal (BCD)
• BCD is a method used to represent decimal digits 0 through 9 using binary
digits.
• BCD coding is the binary equivalent of the decimal digit
• Note: The following table Note: the following 6
shows that BCD coding is bit patterns are not
the binary equivalent of used:
the decimal digit. Please 1010
remember that BCD and 1011
1100
binary are NOT the same.
1101
1110
1111 1-30
(11) Decimal to BCD conversion
Example :
Convert decimal number 87410 to BCD code
Solution :
8 7 4
1 0 0 0 0 1 1 1 0 1 0 0

87410 = 1000 0111 0100BCD

1-31
(12) BCD to Decimal conversion
Example 1:
Convert the BCD code 1 1001 0111 1000BCD to
decimal number.
Solution 1:
A BCD code id converted into a decimal number by
taking groups of 4 bits, starting from right most bit.

1 1001 0111 1000


1100101111000BCD = 197810
1 9 7 8
1-32
(12) BCD to Decimal conversion Note: the following 6
bit patterns are not
What is the answer for the question below? used:
Example 2 :
1010
Convert the BCD code 0111 1100 0001BCD to 1011
decimal number. 1100
Solution 2: 1101
0111 1100 0001 1110
1111
7 1
The forbidden code group
indicates an error in BCD number

1-33
(13) Binary to BCD conversion
Example :
Convert binary 1100012 to BCD code.
Solution :
Step 1. Convert binary code to decimal form.

25 24 23 22 21 20
1 1 0 0 0 1
32 x 1 16 x 1 8x0 4x0 2x0 1 x1
32 + 16 + 0 + 0 + 0 + 1 = 4910
Continue…
1-34
(13) Binary to BCD conversion
Step 2: Convert from Decimal to BCD

4 9
0 1 0 0 1 0 0 1

1100012 = 01001001BCD

1-35
(14) BCD to Binary conversion
Example:
Convert from BCD 0011 0111 0101BCD to binary number
Solution:
Step 1. Convert BCD code to Step 2. Convert
the decimal number
decimal number.
to binary number.

Answer:
0011 0111 0101
0011 0111 0101BCD = 1011101112
3 7 5

1-36
References
• Alan D. Evans, Kendall E. Martin, Mary Anne Poatsy, Technology In Action, 15,
Pearson Higher Education & Professional Group, 2019, ISBN: 9781292311883

• Electronic Coach - https://electronicscoach.com/number-system.html

1-37

You might also like