Number Systems (review)
Objectives
• Understand Digital versus Analog signals
• Number Systems
• Decimal Number System
• Binary Number System
• Hexadecimal Number System
• Positional Numbering System
• Conversions Between Number Systems
1.# Source: Feleke Merin (Dr. – Eng.)
Analog versus Digital signals
• Analog signal
– Continuously varying
– Examples: temperature, pressure, velocity
• Digital signal
– OFF and ON states that can be represented
using 0s and 1s (respectively).
1.# Source: Feleke Merin (Dr. – Eng.)
Analog versus Digital signals (contd.)
1.# Source: Feleke Merin (Dr. – Eng.)
Analog versus Digital signals (contd.)
• Analog Signal Voltages and Their Digital Equivalents
1.# Source: Feleke Merin (Dr. – Eng.)
Analog to Digital signals and back again
1.# Source: Feleke Merin (Dr. – Eng.)
Number Systems
• Two basic types of number systems:
Non-positional
̶ Ex: Roman numerals: I, II, III, IV, V … X, XI … C
̶ Normally only useful for small numbers
̶ Positional Ex: the decimal systems
̶ Each position in which a digit/symbol is written has a
different positional value, which is a power of the base
1.# Source: Feleke Merin (Dr. – Eng.)
Positional Number Systems (Example)
• Decimal number systems
a base of 10 (determines the magnitude of a place).
is restricted to 10 re-usable digits/symbols
(0,1,2,3,4,5,6,7,8,9)
the value of a digit depends on its position (digit x
positional value = digit x base position)
• Sum of the value of all digits gives the value of the number.
58710 = 5 x 102 + 8 x 101 + 7 x 100
= 5 x 100 + 8 x 10 + 7 x 1
= 500 + 80 + 7
= 587
1.# Source: Feleke Merin (Dr. – Eng.)
Positional Number Systems (Example)
• Decimal (base is 10):
375.1710 = 3 x 102 + 7 x 101 + 5 x 100 + 1 x 10-1 + 7 x 10-2
= 3 x 100 + 7 x 10 + 5 x 1 + 1 x 0.1 + 7 x 0.01
= 300 + 70 + 5 + 0.1 + 0.07
= 375.17
1.# Source: Feleke Merin (Dr. – Eng.)
Paractice session
• Specify the value of the digit 5 in the following
decimal numbers:
25
51
4538
Answer: the 5 in 25 = 5 x 100 = 5
the 5 in 51 = 5 x 101 = 50
the 5 in 4538 = 5 x 102 = 500
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal Binary
(base 10) (base 2)
Common number systems 0 0
1 1
2 10
• Decimal 3 11
4 100
– Base 10 5 101
– 10 symbols 6 110
7 111
0, 1, 2, 3, 4, 5, 6, 7, 8, 8 1000
9 9 1001
10 1010
11 1011
• Binary 12 1100
– Base 2 13 1101
14 1110
– 2 symbols: 0, 1 15 1111
16 10000
... ...
1.# Source: Feleke Merin (Dr. – Eng.)
Octal Hexadecimal
(base 8) (base 16)
Common number systems 0 0
1 1
• Octal 2
3
2
3
– Base 8 4 4
5 5
– 8 symbols
6 6
0, 1, 2, 3, 4, 5, 6, 7 7 7
• Hexadecimal
10
11
8
9
– Base 16 12 A
13 B
– 16 symbols
14 C
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 D
A, B, C, D, E, F 16 E
– More compact representation 17 F
20 10
of the binary system
... ...
1.# Source: Feleke Merin (Dr. – Eng.)
Why so many number systems?
• Digital & microprocessor-based electronic
circuitry use the binary number system.
• Man use the decimal number system.
• Because the binary number system uses only 0 and
1, it is hard for us to work with such huge binary
numbers.
• Example: 1001111101110111011011102
• Errors are usually the rule when working only in the
binary number system.
1.# Source: Feleke Merin (Dr. – Eng.)
Why so many number systems? (contd.)
• Another number system that resembles the
decimal number system is the hexadecimal
number system.
• The hexadecimal or base 16 number system has 16
symbols, some of which are the first 6 letters of the
alphabet.
• This number system is also used with digital
systems.
• This system is usually referred to as Hex (short for
hexadecimal).
1.# Source: Feleke Merin (Dr. – Eng.)
Number Systems Conversions
Binary Numbering systems
• Base: 2
• Digits: 0, 1
• binary number: 1101012
positional powers of 2: 25 24 23 22 21 20
decimal positional value: 32 16 8 4 2 1
binary number: 1 1 0 1 0 1
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Decimal Conversion
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Decimal Conversion (contd.)
Ex: 1010112
positional powers of 2: 25 24 23 22 21 20
decimal positional value:
binary number:
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Binary Conversion
The Division Method. Divide by 2 until you reach
zero, and then collect the remainders in reverse.
Ex 1: 5610 = 1110002
2 ) 56 Rem:
2 ) 28 0
2 ) 14 0
2) 7 0
2) 3 1
2) 1 1
0 1
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Binary Conversion(contd.)
Ex 2: 3510 =
2) Rem:
2)
2)
2)
2)
2)
Answer: 3510 = 2
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Binary Conversion(contd.)
The Subtraction Method:
Subtract out largest power of 2 possible (without
going below zero) each time until you reach 0.
Place a one in each position where you were able
to subtract the value, and a 0 in each position that
you could not subtract out the value without going
below zero.
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Binary Conversion(contd.)
Ex 1: 5610
56 26 | 25 24 23 22 21 20
- 32 64 | 32 16 8 4 2 1
24 | 1 1 1 0 0 0
- 16
8
- 8
0
Answer: 5610 = 1110002
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Binary Conversion(contd.)
Ex 2: 3810
38 26 | 25 24 23 22 21 20
|
|
Answer: 3810 = 2
1.# Source: Feleke Merin (Dr. – Eng.)
Octal Numbering systems
• Base: 8
• Digits: 0, 1, 2, 3, 4, 5, 6, 7
• Octal number: 12468
powers of : 84 83 82 81 80
decimal value: 4096 512 64 8 1
Octal number: 1 2 4 6
1.# Source: Feleke Merin (Dr. – Eng.)
Octal to Decimal Conversion
• To convert to base 10, beginning with the
rightmost digit multiply each nth digit by 8(n-1), and
add all of the results together.
Ex: 12468
positional powers of 8: 83 82 81 80
decimal positional value: 512 64 8 1
Octal number: 1 2 4 6
512 + 128 + 32 + 6 = 67810
1.# Source: Feleke Merin (Dr. – Eng.)
Octal to Decimal Conversion(contd.)
Ex: 103528
positional powers of 8: 84 83 82 81 80
decimal positional value:
Octal number:
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Octal Conversion
The Division Method. Divide by 8 until you reach
zero, and then collect the remainders in reverse.
Ex 1: 433010 = 103528
8 ) 4330 Rem:
8 ) 541 2
8 ) 67 5
8) 8 3
8) 1 0
0 1
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Octal Conversion(contd.)
Ex 2: 81010 =
8 ) 810 Rem:
8)
8)
8)
Answer: 81010 = 8
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Octal Conversion(contd.)
The Subtraction Method:
Subtract out multiples of the largest power of 8
possible (without going below zero) each time until
you reach 0. Place the multiple value in each
position where you were able to subtract the value,
and a 0 in each position that you could not
subtract out the value without going below zero.
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Octal Conversion(contd.)
Ex 1: 201810
2018 84 | 83 82 81 80
- 1536 4096 | 512 64 8 1
482 | 3 7 4 2
- 448
34
- 32
2
- 2
0 Answer: 201810 = 37428
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Octal Conversion(contd.)
Ex 2: 76510
765 84 | 83 82 81 80
|
|
Answer: 76510 = 13758
1.# Source: Feleke Merin (Dr. – Eng.)
Hexadecimal Numbering systems
• Base: 16
• Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
• Hexadecimal number: 1F416
powers of : 164 163 162 161 160
decimal value: 65536 4096 256 16 1
Hexadecimal number: 1 F 4
1.# Source: Feleke Merin (Dr. – Eng.)
Hexa to Decimal Conversion
• To convert to base 10, beginning with the rightmost digit
multiply each nth digit by 16(n-1), and add all of the results
together.
Ex: 1F416
positional powers of 16: 163 162 161 160
decimal positional value: 4096 256 16 1
Hexadecimal number: 1 F 4
256 + 240 + 4 = 50010
1.# Source: Feleke Merin (Dr. – Eng.)
Hexa to Decimal Conversion(contd.)
Ex: 7E16
positional powers of 16: 163 162 161 160
decimal positional value:
Hexa number:
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Hexa Conversion
The Division Method. Divide by 16 until you
reach zero, and then collect the remainders
in reverse.
Ex 1: 12610 = 7E16
Ex 1: 12610 = 7E16
16) 126 Rem:
16) 7 4=E
0 7
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Hexa Conversion(contd.)
Ex 2: 81010 =
16 ) 810 Rem:
16 )
16 )
Answer: 81010 = 16
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Hexa Conversion(contd.)
The Subtraction Method:
Subtract out multiples of the largest power of 16
possible (without going below zero) each time until
you reach 0. Place the multiple value in each
position where you were able to subtract the value,
and a 0 in each position that you could not subtract
out the value without going below zero.
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Hexa Conversion(contd.)
Ex 1: 81010
810 163 | 162 161 160
- 768 4096 | 256 16 1
42 | 3 2 A
- 32
10
- 10
0 Answer: 81010 = 32A16
1.# Source: Feleke Merin (Dr. – Eng.)
Decimal to Hexa Conversion(contd.)
Ex 2: 15610
156 162 | 161 160
|
|
Answer: 15610 = 16
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Octal Conversion
Since the maximum value represented in 3 bit is equal
to:
23 – 1 = 7
i.e. using 3 bits we can represent values from 0 –7
which are the digits of the Octal numbering system.
Thus, three binary digits can be converted to one octal
digit and visa versa.
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Octal Conversion(contd.)
Ex : Convert 101001102 = 8
110 = 6
100 = 4
010 = 2 ( pad empty digits with 0)
101001102 = 2468
1.# Source: Feleke Merin (Dr. – Eng.)
Octal to Binary Conversion
Ex : Convert 7428 = 2
2 = 010
4 = 100
7 = 111
7428 = 111 100 0102
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Hexa Conversion
Since the maximum value represented in 4 bit is
equal to:
24 – 1 = 15
i.e. using 4 bits we can represent values from 0 –15
which are the digits of the Hexadecimal numbering
system.
Thus, Four binary digits can be converted to one
Hexadecimal digit.
1.# Source: Feleke Merin (Dr. – Eng.)
Binary to Hexa Conversion)contd.)
Ex : Convert 101001102 = 16
0110 = 6
1010 = A
101001102 = A616
1.# Source: Feleke Merin (Dr. – Eng.)
Hexa to Binary Conversion
Ex : Convert 3D916 = 2
9 = 1001
D = 1101
3 = 0011
3D916 = 0011 1101 10012
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Octal to Hexa Conversion
• To convert between Octal to Hexadecimal
numbering systems and visa versa convert from
one system to binary first then convert from
binary to the new numbering system
Ex : Convert 7528 = 16
111 101 0102 (group by 4 bits)
0001 1110 1010
1 E A
7528 = 1EA16
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Hexa to Octal Conversion
Ex : Convert E8A16 = 8
1110 1000 10102
111 010 001 010 (group by 3 bits)
7 2 1 2
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Practice Converting these decimal numbers to
binary
Answers:
4410
4410 = 1011002
11710 11710 = 11101012
14210 14210 = 100011102
25510 = 111111112
25510
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Convert the following decimal numbers to
octal
Answers
7910
7910 = 1178
19410 19410 = 3028
20810 20810 = 3208
25510 = 3778
25510
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Practice converting the following decimal
numbers to hexadecimal.
Answers
5710
5710 = 3916
13810
13810 = 8A16
21710
21710 = D916
25510
25510 = FF16
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert the following binary numbers to octal.
Answers
011011002 011011002 = 1548
101100112 101100112 = 2638
001010012 001010012 = 0518
111111112 111111112 = 3778
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert the following octal numbers to
binary.
Answers
0378 0378 = 001111112
1168 1168 = 010011102
1458 1458 = 011001012
2738 2738 = 101110112
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert the following binary numbers to
hexadecimal.
Answers
000010102 000010102 = 0A16
100111102 100111102 = 9E16
111100112 111100112 = F316
011111012 011111012 = 7D16
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert the following hexadecimal
numbers to binary.
Answers
1B16 1B16 = 000110112
9416 9416 = 100101002
A516 A516 = 101001012
FB16 FB16 = 111110112
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert the following numbers to their
decimal equivalents
10011012
1101.112
1AB.616
173.25 8
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Answer:
• 10011012 = 1 x 26 + 0 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21+1 x 20
= 64 + 0 + 0 + 8 + 4 + 0 + 1
= 7710
• 1101.112 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 + 1 x 2-1 + 1 x 2-2
= 8 + 4 + 0 + 1 + 1/2 + 1/4
= 13.7510
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Answer:
• 1AB.616 = 1 x 162 + A x 161 + B x 160 + 6 x 16-1
= 1 x 256 + 10 x 16 + 11 x 1 + 6 x 16
= 256 + 160 + 11 + 0.375
= 427.37510
• 173.258 = 1 x 82 + 7 x 81 + 3 x 80 + 2 x 8-1 + 5 x 8-2
= 1 x 64 + 7 x 8 + 3 x 1 + 2/8 + 5/64
= 64 + 56 + 3 + 0.25 + 0.078125
= 123.32812510
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert 123|10 to Base 8
• Convert 59|10 to Base 2
• Convert 42|10 to Base 16
Answer
Convert 123|10 to Base 8:
8 ) 123
8 ) 15 R 3
8)1 R 7 Read Up!
0 R 1
Therefore, 123|10 = 173|8
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Answer
• Convert 59|10 to Base 2:
59|10 =1110112
• Convert 42|10 to Base 16:
16 )42
16 )2 R A
Read Up!
0 R 2
Therefore, 42|10 = 2A|16
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Do you know the equivalent hexadecimal, octal, and
decimal values of the binary number 11001010?
______Yes _______No
• If you answered Yes, please indicate them below:
– Equivalent hexadecimal number:__CA___________
– Equivalent octal number: _______312___________
– Equivalent decimal number: ____202_____________
• What is the equivalent binary number of the decimal
number 63? ________111111_____________
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
• Convert 18110 to binary and hex
• Convert 121F16 to decimal
• Convert 010101011002 to hex
• Convert A17F16 to octal
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Practice session
Answers
• Convert 18110 to binary (10110101) and hex (B5)
• Convert 121F16 to decimal (4639 10 )
• Convert 010101011002 to hex (2AC16)
• Convert A17F16 to octal (1205778)
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
The ASCII Code
• American Standard Code for Information
Interchange (ASCII)
– Represents alphanumeric data
– Uses 7 bits
• 128 different code combinations
– 3-bit group is most significant
– 4-bit group is least significant
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Numbering System Applications
• Because digital systems must work with 1s and 0s,
learning the different numbering systems is
important.
• Which system is used is determined by how the
data were developed and how they are to be used.
• Several numbering system applications follow.
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1
• The four chemical storage tanks shown are monitored
for temperature (T) and pressure (P).
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1 (continued)
• Using the table shown below, interpret the
following:
– If the computer reads a binary string of
0010 1000 what problems exist?
– This indicates that the pressure in tanks C and
B are too high.
0 0 1 0 1 0 0 0
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1 (continued)
• Using the table shown below, interpret the
following:
– If the computer reads a hex value of 55H what
problems exist?
– Since 55H =0101 0101 This indicates that all
tank temperatures are too high.
0 1 0 1 0 1 0 1
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1 (continued)
• Using the table shown below, interpret the following:
– If the temperature and pressure in tanks B and D
are too high, what hex value is read by the
computer?
– This condition would produce a digital output of
1100 1100 = CCH.
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1 (continued)
• Using the table shown below, interpret the following:
– Assume that tanks A and B are shut down and all
sensors are tied high (1s). What is the lowest decimal
value that indicates a problem in the other two tanks?
– With the four low-order bits tied high, the lowest value
that indicates a problem is 0001
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Application 1-1 (continued)
• Using the table shown below, interpret the following:
– If only tanks A, B, and C are monitored, what octal
value indicates tank B has both temperature and
pressure problems?
– The binary output would be 001 1002 = 148.
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Summary
• Any number system can be converted to decimal by
multiplying each digit by its weighting factor.
• The weighting factor for the least significant digit in
any number system is always 1.
• Binary numbers can be converted to octal by
forming groups of 3 bits and to hexadecimal by
forming groups of 4 bits.
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)
Summary
• The successive division procedure can be used to
convert from decimal to binary, octal, or hexadecimal.
• The binary-coded-decimal system uses groups of 4 bits
to drive decimal displays such as those in a calculator.
• ASCII is used by computers to represent all letters,
numbers and symbols in digital form.
The End
Course Title: Computer Architecture & Organization 1.# Source: Feleke Merin (Dr. – Eng.)