0% found this document useful (0 votes)
18 views39 pages

Digital Electronics 2

Uploaded by

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

Digital Electronics 2

Uploaded by

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

Number Systems

numerical representations
different bases (binary, octal, hexadecimal, BCD)
conversion between the different bases
Arithmetic

1
Data
Representation
• Many number systems are in use in digital
technology

• Most common are


– Decimal (0, 1, 2, 3, 4, …, 9)
– Binary (0, 1)
– Octal (0, 1, 2, …, 7)
– Hexadecimal (0, 1, 2, …, A, B, …,E,F)
– BCD (a special case of 0, 1, 2, 3, 4, …, 9)

2
Understanding Decimal Numbers
• Decimal numbers are made of 10 digits or
numerals or symbols: (0,1,2,3,4,5,6,7,8,9)
– Why do we use 10 digits, anyway?
– Latin word digit == finger

MSD
LSD
4 3 2 1 0 -1 -2
3 5 1 4 2 . 3 7

But how many items does a decimal number represent?


3 2 1 0
8653 = 8x10 + 6x10 + 5x10 + 3x10

What about fractions?


4 3 2 1 0 -1 -2
97654.35 = 9x10 + 7x10 + 6x10 + 5x10 + 4x10 + 3x10 + 5x10
In formal notation -> (97654.35)10
3
Question
Express the decimal number 568.23 as a sum
of the values of each digit

4
Binary Numbers

5
Question

• What is the largest decimal number that


can be represented in binary with 8 bits

6
Understanding Octal Numbers
• Octal numbers are made of octal digits:
(0,1,2,3,4,5,6,7)
• How many items does an octal number
represent?
– (4536)8 = 4x83 + 5x82 + 3x81 + 6x80 = (1362)10

• What about fractions?


– (465.27)8 = 4x82 + 6x81 + 5x80 + 2x8-1 + 7x8-2

• Octal numbers don’t use digits 8 or 9

• Where can octal numbers find practical


applications?
7
Hexadecimal Numbers
• Hexadecimal numbers are made of 16 digits:
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

HEX BINARY HEX BINARY

0 0000 8 1000
1 0001 9 1001
2 0010 B 1011
3 0011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111

8
Summary
• Decimal number, octal number does not lend itself
to convenient implementation in digital systems

• Difficult to design electronics systems with


10 different voltage levels each one
representing one decimal character (0-9)
• On the other hand using binary it becomes
easy to design simple , accurate electronic
circuits that operates with only two voltage
levels. 1 and 0
• For that matters almost all digital systems
use the binary number
9
Conversion Between Number Bases
 Learn to convert between bases.
 Decimal to any base
 Binary to decimal
 Hexadecimal to decimal
 Octal to decimal
 BCD
Octal( base 8)

Decimal (base 10) Binary (base 2)

Hexadecimal
(base16)
10
Convert an Integer from Decimal to Another Base

For each digit position:


1. Divide decimal number by the base (e.g. 2)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.

11
Convert an Integer from Decimal to Another Base

• Convert the following decimal numbers to


binary
a) 19
b) 45
c) 108
d) 72
e) 36

12
Convert a Fraction from Decimal to Another Base

For each digit position:


1. Multiply decimal number by the base (e.g. 2)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes
zero.
Example for (0.625)10:
Integer Fraction Coefficient

0.625 x 2 = 1 + 0.25 a -1 = 1
0.250 x 2 = 0 + 0.50 a -2 = 0
0.500 x 2 = 1 + 0 a -3 = 1

Answer (0.625)10 = (0.a-1 a-2 a-3 )2 = (0.101)2

13
Binary Numbers--Base
2
• Computers represent all data as “strings of
bits”, each bit being either 0 or 1
• “base” 2, with 2 digits: 0 and 1
• e.g.
(101101.10)2 = 125 + 024 + 123 + 122
+ 021 + 120 + 12-1 + 02-2
(In decimal) = 32 + 0 + 8 + 4 + 0 + 1 + ½ + 0
= (45.5)10
14
Binary Numbers--Base 2

• e.g.
(1001.011)2 = 123 + 022 + 021 + 120
+02-1 + 12-2 + 12-3

(In decimal) = 8 + 1 + 0.25 + 0.125


= (9.375)10

15
Binary to Decimal - Example

• ex) Convert 1011 to decimal

2 3 22 21 20 (weight)
1 0 1 1

= 1•(23)+ 0• (22)+1•(21)+1•(20)
= 1•(8)+ 0•(4)+1•(2)+1•(1)
= 8+0+2+1
= 11 Decimal
16
The Growth of Binary Numbers

n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024
3 23=8 11 211=2048
4 24=16 12 212=4096 Mega
5 25=32 20 220=1M Giga
6 26=64 30 230=1G Tera
7 27=128 40 240=1T

17
Convert an Integer from Decimal to Octal

For each digit position:


1. Divide decimal number by the base (8)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.

Example for (175)10:


Integer Remainder Coefficient
Quotient
175/8 = 21 + 7/8 a0 = 7
21/8 = 2 + 5/8 a1 = 5
2/8 = 0 + 2/8 a2 = 2

Answer (175)10 = (a2 a1 a0)2 = (257)8


18
Convert a Fraction from Decimal to Octal

For each digit position:


1. Multiply decimal number by the base (e.g. 8)
2. The integer is the highest-order digit
3. Repeat first two steps until fraction becomes zero.

Example for (0.3125)10:

Integer Fraction Coefficient

0.3125 x 8 = 2 + 5 a-1 =
2
0.5000 x 8 = 4 + 0 a-2 =
4 Answer (0.3125)10 = (0.24)8
19
Binary to Octal and Hexadecimal
• Basics
• Octal:
8 = 23  every 3 binary bits convert to 1
octal

• Hex:
16 = 24  every 4 binary bits convert to 1
hexadecimal

20
Binary to Octal Conversion
Standard Binary to Octal Conversion Table

Octal 0 1 2 3 4 5 6 7
Binary 000 001 010 011 100 101 110 111

Example:

(011 010 101 000 . 111 101 011 100)2

(3 2 5 0 . 7 5 3 4 )8

21
Hexadecimal to Binary Conversion
HEX BINARY HEX BINARY
0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111

Example
1D7F16 = (0001 1101 0111 1111)2
1 D 7 F

5AB216 = (0101 1010 1011 0010)2


5 A B 2
22
Binary to Hexadecimal Conversion
Standard Binary to Hexadecimal Conversion Table

Binary 0000 0001 0010 0011 0100 0101 0110 0111

Hexa 0 1 2 3 4 5 6 7

Binary 1000 1001 1010 1011 1100 1101 1110 1111

Hexa 8 9 10(A) 11(B) 12(C) 13(D) 14(E) 15(F)

Example:
(1110 0011 0000 1100)2 = E30C16
E 3 0 C

1001 1000 1101 111116 = 98DF16


9 8 D F
23
Converting from Binary to Hexadecimal
• Every four bits makes one hexadecimal
digit
start grouping from right-hand side
Make each group into a hexadecimal digit
Example

011101010001111010011010111

3 A 8 F 4 D 7

24
Binary  Hex Conversions
Binary to Hexadecimal - Example

( 0110 1010 1000 . 1111 0101 1100 )2

( 6 A 8 . F 5 C )16

25
Hex to Binary Base Conversion
Hexadecimal to Binary - Example
• Each HEX digit is made up of four binary bits
ex) Convert ABC to binary

A B C
1010 1011 1100

 (ABC)16 (101010111100)2

26
Converting from Hexadecimal to Decimal
• Every hex digit position has a base value
– multiply the value at the position by the base value

8 4 D 7

(84D7)16 = 8x163+4x162+13x161+7x160
= 8x4096+4x256+13x16+7x1
= 32768+1024+208+7
= (34007)10

27
Octal
• Octal is simply “base 8” number representation

010011010111

2 3 2 7
Octal and Hex Practice
Hex (4 9 5)16

011010010101

Octal (3 2 2 5)8
28
Octal  Hex

Go through Binary!

Hex  Binary  Octal

Octal  Binary  Hex

29
Binary Coded Decimal (a.k.a. 8421 code)

• Sometimes we wish to represent an individual


decimal digit as a binary representation (i.e., 7-
segment display to eliminate a decoder)

• We do this by using 4 binary digits


Decimal BCD
0 0000
1 0001 ex) Represent (17)10
2 0010
3 0011 Binary = 10111
4 0100 BCD = 0001 0111
5 0101
6 0110
7 0111
8 1000
9 1001 30
Binary Coded Decimal
Digit BCD Digit BCD
Code Code
0 0000 5 0101
1 0001 6 0110
2 0010 7 0111
3 0011 8 1000
4 0100 9 1001

• Binary coded decimal (BCD) represents each decimal digit with


four bits  Ex. 0011 0010 1001 = 32910

• This is NOT the same as 0011001010012


° 235810  00100011010110002
31
Putting It All Together

32
BCD

° BCD not very efficient


° Used in early computers (40s, 50s)
° Used to encode numbers for seven-segment
displays.

33
Binary Arithmetic
Binary arithmetic is essential in all digital computers
and in many other types of digital systems

The four basic rules for adding binary digits


(bits) are as follows: -

0 + 0 = 0  Sum of 0 with a carry of 0

0 + 1 = 1  Sum of 1 with a carry of 0

1 + 0 = 1  Sum of 1 with a carry of 0

1 + 1 = 0  Sum of 0 with a carry of 1


34
Binary Arithmetic
• Base-2 addition
– just like base-10
-- add from right to left
-- propagating carry

carry
10010 10010 1111
+ 1001 + 1011 + 1
11011 11101 10000

35
Binary Subtraction

The four basic rules for


subtracting binary digits (bits) are as
follows

0-0=0
1-1 =1
1-0 =1
0 - 1 = 1 0-1 with a borrow -1

36
BINARY MULTIPLICATION

The four basic rules for


multiplying binary digits (bits) are
as follows: -

0 x 0 = 0

0 x 1 = 0

1 x 0 = 0

1 x 1 = 1
37
Question

38
Summar
y
• Binary numbers are made of binary digits
(bits)

• Binary and octal number systems

• Conversion between number systems

• Binary Addition, subtraction, and


multiplication
39

You might also like