Tải bản đầy đủ (.pdf) (59 trang)

Lecture Digital logic design - Lecture 2: More number systems/complements

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (768.92 KB, 59 trang )

Digital Logic Design
Lecture 2
More Number Systems/Complements

1


Overvie
w
° Hexadecimal numbers
• Related to binary and octal numbers

° Conversion between hexadecimal, octal and binary
° Value ranges of numbers
° Representing positive and negative numbers
° Creating the complement of a number
• Make a positive number negative (and vice versa)

° Why binary?

2


Understanding Binary Numbers
°

Binary numbers are made of binary digits (bits):


°


How many items does an binary number represent?


°

(110.10)2 = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2

Groups of eight bits are called a byte


°

(1011)2 = 1x23 + 0x22 + 1x21 + 1x20 = (11)10

What about fractions?


°

0 and 1

(11001001) 2

Groups of four bits are called a nibble.


(1101) 2

3



Understanding Hexadecimal
Numbers
°

Hexadecimal numbers are made of 16 digits:


°

How many items does an hex number represent?


°

(2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 = 723.312510

Note that each hexadecimal digit can be represented
with four bits.


°

(3A9F)16 = 3x163 + 10x162 + 9x161 + 15x160 = 1499910

What about fractions?


°


(0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)

(1110) 2 = (E)16

Groups of four bits are called a nibble.


(1110) 2

4


Putting It All
Together
°

Binary, octal, and
hexadecimal similar

°

Easy to build circuits to
operate on these
representations

°

Possible to convert
between the three
formats


5


Converting Between Base 16 and Base
2
3A9F16 = 0011 1010 1001 11112
3

°

A

9

F

Conversion is easy!
 Determine 4-bit value for each hex digit

°

Note that there are 24 = 16 different values of four
bits

°

Easier to read and write in hexadecimal.

°


Representations are equivalent!

6


Converting Between Base 16 and Base
8
3A9F16 = 0011 1010 1001 11112
3

352378 =

A

9

F

011 101 010 011 1112
3

5

2

3

7


1. Convert from Base 16 to Base 2
2. Regroup bits into groups of three starting from
right
3. Ignore leading zeros
4. Each group of three bits forms an octal digit.
7


8


Decimal 2 Binary

9


Number systems (Octal
Numbers)
(
Octal Numbers:
[Base 8],[ 0,1,3,4,5,6,7]

Octal to Decimal Conversion:
Example:[2374]8 = [ ? ]10
=4×80+7×81+3×82+2×83
=[1276]10

°Octal number has base 8
°Each digit is a number from 0 to 7
°Each digit represents 3 binary bits

°Was used in early computing, but was
replaced by hexadecimal

10


Number systems (Octal
Numbers)
(

Decimal to Octal Conversion:
The Division:
[359]10 = [ ? ]8
By using the division system:

359 Quotient
44
8
44
5
8
5
0
8

Reminder

7
4
5


5

4

7

11


Number systems (Octal
Numbers)
(

Binary to Octal Conversion:
Example:[110101]2 = [ ? ]8
Here we will take 3 bits and convert it from binary to
decimal by using the decimal to binary truth table:

Decimal

6

101

5

110
6


101

= (65)8

{

110

{

Binary

5
12


Number systems (Octal
Numbers)
(

Octal to Binary Conversion:
Example:[13]8 = [ ? ]2
Here we will convert each decimal digit from decimal
to binary (3 bits) using the decimal to binary truth
table:
Binary

Decimal

1


001

3

011

(13)8

= (001011)2

13


Rad
ix
°Bas
Convert 1234 decimal into octal
ed
Con
ver
sio
n
(Ex
Radix 8
123
am
8
4
ple)

Divide

by radix 8

8 154
8 19
2

2
2
3

Answer

23228

14


Octals



Converting to decimal from octal:
– Evaluate the power series
Example

2

1


0

2 0 78
2*82

+

0*81
=

+

7*80

13510
15


Hexadecimal
° Hexadecimal is used to simplify dealing with large
binary values:
• Base-16, or Hexadecimal, has 16 characters: 0-9, A-F
• Represent a 4-bit binary value: 00002 (0) to 11112 (F)
• Easier than using ones and zeros for large binary
values
• Commonly used in computer applications
° Examples:
• 11002 = 1210 = C16
• 1010 0110 1100 00102 = A6 C216

Hex values can be followed by an “H” to indicate base-16.
Example: A6 C2 H
16


Hex Values in Computers

17


Decimal to Hexadecimal
Decimal

Hex

0

0

1

1

2

2

3

3


4

4

5

5

6

6

7

7

8

8

9

9

10

A

11


B

12

C

13

D

14

E

15

F

18


Conversion Binary to Hexadecimal

1 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0
1010 = 10

1100 = 12

A


C

0001 = 1

1

0110 = 6

6

19


Rad
ix
°Bas
Convert 1234 decimal into hexadecimal
ed
Con
ver
sio
n
(Ex
Radix 16
am
123
16
4
ple)

Divide

by radix 16

16

77
4

2
D

Answer

4D216

20


Hexadecimals – Base 16



Converting to decimal from hex:
– Evaluate the power series
Example

2

1


0

2 E A 16
2*162

+

14*161
=

+

10*160

74610
21


Octal to Hex Conversion

 To convert between the Octal and Hexadecimal
numbering systems
 Convert from one system to binary first
 Then convert from binary to the new numbering
system

22



Hex to Octal Conversion

Ex : Convert E8A16 to octal
First convert the hex to binary:
1110 1000 10102
111 010 001 010 and re-group by 3 bits
(starting on the right)
Then convert the binary to octal:
7

2

1

2

So E8A16 = 72128
23


Octal to Hex Conversion

Ex : Convert 7528 to hex
First convert the octal to binary:
111 101 0102 re-group by 4 bits
0001 1110 1010

(add leading zeros)

Then convert the binary to hex:

1

E

A

So 7528 = 1EA16
24


Oct
al to 
Hex
adec
imal
Decimal

Octal

Binary

Hexadecimal

25


×