Module 1 _ Number System

63
Digital Logic Digital Logic Design Design Module 1 : Number Systems Prof. Hansa Shingrakhia Electronics and Communication Engineering Department Indus Institute of T echnology and Engineering

Transcript of Module 1 _ Number System

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 1/63

Digital LogicDigital Logic

DesignDesignModule 1 : Number Systems

Prof. Hansa Shingrakhia

Electronics and Communication Engineering Department

Indus Institute of Technology and Engineering

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 2/63

�Number s stems

�Decimal s stem

� Bi ar , ctal and  ex s stems

�Number conversion, decimal to binar , binar

to decimal

�Complements

Subtraction met ods�Codes: Binar , Gray, Error detection

� Binary Logic

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 3/63

� A bit is a single binary digit (a  or 0).

� A byte is 8 bits

� A word is 32 bits or 4 bytes

� Long word = 8 bytes = 64 bits� Quad word = 6 bytes = 28 bits

� Programming languages use t ese standard number of bits w en organizing data storage and access.

� W at do you call 4 bits?( int: it is a small byte)

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 4/63

System Base Symbols

Used byhumans?

Used in

computers?

Decimal 0 0, , « 9 Yes No

Binary 2 0, No Yes

Octal 8 0, , « 7 No No

Hexa-

decimal

6 0, , « 9,

A, B, « F

No No

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 5/63

�The decimal system is composed of 0

numerals or symbols. These 0 symbols are 

0, , 2, 3, 4, 5, 6, 7, 8, 9. Using these 

symbols as digits of a number, we can express any quantity. The decimal system is

also called the base-10 system because it has

10 digits.

� The decimal number system is a positionalnumber system

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 6/63

103 102 101 100 10-1 10-2 10-3

=1000 =100 =10 =1 . =0.1  =0.01  =0.001

Most

Significant

Digit

Decimal

point

Least

Significant

Digit

Even though the decimal system has only 10 symbols, any number of 

any magnitude can be expressed by using our system of positional

weighting.

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 7/63

�N = (an-1an-2 ... a1a0  . a-1a-2 ... a-m)r where . = radix point

r = radix or base

n = number of integer digits to the left of

the radix point

m= number of fractional digits to the

right of the radix point

an-1 = most significant digit (MSD)

a-m = least significant digit (LSD)

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 8/63

N = an-1 x r n-1 + an-2 x r n-2 + ... + a0  x r 0  + a-1 x r -1

... + a-m x r -m

= (an-1  an-2 «. a0  a-1 «. a-m )

Ex ample 

N = (251.41)10  (Positional N otation)= 2 x 102 + 5 x 101 + 1 x 100  + 4 x 10-1 + 1 x 

10-2 (Polynomial N otation)

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 9/63

� 5 6 2 1 1 X 100 =  1

103 102 101 100 2 X 101  = 20

6 X 102 = 600

5 X 103 = 5000

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 10/63

� In the binary system there are only two 

symbols or possible digit values, 0 and 1. This

base-2 system can be used to represent any 

quantity that can be represented in decimalor other base system.

23 22 21 20 2-1 2-2 2-3

=8

=4

=2

=1 .

=0.5

=0.25

=0.125

Most

Signifi

cant

Digit

Binary 

point

Least

Signifi

cant

Digit

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 11/63

�The Binary counting 

sequence is shown inthe table:

23 22 21 20 Decimal

0 0 0 0 0

0 0 0 1 1

0 0 1 0 2

0 0 1 1 3

0 1 0 0 4

0 1 0 1 5

0 1 1 0 60 1 1 1 7

1 0 0 0 8

1 0 0 1 9

1 0 1 0 10

1 0 1 1 11

1 1 0 0 12

1 1 0 1 13

1 1 1 0 14

1 1 1 1 15

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 12/63

� In digital systems the information that is

being processed is usually presented in 

binary form. Binary quantities can be 

represented by any device that has only two operating states or possible conditions. E.g..

a switch is only open or closed. We 

arbitrarily (as we define them) let an open 

switch

represent binary 0 and a closed switch represent binary 1. Thus we can represent

any binary number by using series of 

switches.

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 13/63

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 14/63

�Binary 1: Any voltage between 2V to 5V

�Binary 0: Any voltage between 0V to 0.8V

�Not used: Voltage between 0.8V to 2V in 5

Volt CMOS and TTL Logic, this may cause error in a digital circuit. Today's digital

circuits wor s at 1.8 volts, so this statement

may not hold true for all logic circuits.

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 15/63

�The octal number system has a base of eight,

meaning that it has eight possible digits:

0,1,2,3,4,5,6,7.

�Each Octal number is equivalent to 3 binary bits

83 82 81 80 8-1 8-2 8-3

=512 =64 =8 =1 . =1/8 =1/64 =1/512

Most

Significant

Digit

Octal

point

Least

Significant

Digit

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 16/63

�Octal to Decimal Conversion2378 =

2 x (82) + 3 x (81) + 7 x (80) = 15910

11.18 =

1 x (81) + 1 x (80) + 1 x (8-1) = 9.12510

To convert binary to octal make groups of 3 bits

each from right and replace each group with octal

number 

0101010111010011

0 101 010 111 010 011

0 5 2 1 2 3

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 17/63

�The hexadecimal system uses base 16. Thus,

it has 16 possible digit symbols. It uses the 

digits 0 through 9 plus the letters A, B, C, D,

E, and F as the 16 digit symbols.�

163 162 161 160 16-1 16-2 16-3

=4096 =256 =16 =1 . =1/16

=1/25

6

=1/40

96

Most

Significant

Digit

Hexa 

Decimal

point

Least

Significant

Digit

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 18/63

�Hexadecimal to Decimal Conversion

24.616 =

2 x (161) + 4 x (160) + 6 x 

(16-1) = 36.37510

To convert binary to hex, make groups

of 4 binary bits beginning with LSB.

Write equivalent symbol for eachgroup.

Binary Decimal Hexa-

decimal

0000 0 0

0001 1 1

0010 2 2

0011 3 3

0100 4 4

0101 5 5

0110 6 6

0111 7 7

1000 8 8

1001 9 9

1010 10 A

1011 11 B

1100 12 C

1101 13 D

1110 14 E

1111 15 F

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 19/63

�Converting from one code form to 

anoth

er code form is called code conversion, li e converting from 

binary to decimal or converting from 

hexadecimal to decimal.

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 20/63

Conversion Among Bases

� The possibilities:

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 21/63

Hexadeci al

Deci al Octal

Binary

Next slide«

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 22/63

12510

=> 5 x 100= 5

2 x 101= 20

1 x 10

2

= 100125

Base

Weight

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 23/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 24/63

�Technique

� Multiply each bit by 2n, where n is the ´weightµ

of the bit 1

� The weight is the position of the bit, starting from 0 on the right

� Add the results

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 25/63

1010112 => 1 x 20 = 1

1 x 21 = 2

0 x 22 = 0

1 x 23 = 8

0 x 24 = 0

1 x 25 = 32

4310

Bit ³0´

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 26/63

� Binary to decimal

�10.1011 => 1 x 2-4 = 0.0625

1 x 2-3 = 0.125

0 x 2-2

= 0.01 x 2-1 = 0.5

0 x 20 = 0.0

1 x 21 = 2.0

2.6875

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 27/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 28/63

�Technique� Multiply each bit by 8n, where n is the ´weightµ of 

the bit

� The weight is the position of the bit, starting from 0

on the right� Add the results

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 29/63

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 30/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 31/63

�Technique� Multiply each bit by 16n, where n is the ´weightµ of 

the bit

� The weight is the position of the bit, starting from 0

on the right� Add the results

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 32/63

ABC16

=> C x 160 = 12 x 1 = 12

B x 161 = 11 x 16 = 176

A x 162 = 10 x 256 = 2560

274810

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 33/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 34/63

�Technique� Divide by two, eep track of the remainder

� First remainder is bit 0 (LSB, least-significant bit)

� Second remainder is bit 1

� Etc.

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 35/63

12510 = ?22 125

62 12

31 02

15 12

7 12

3 12

1 12

0 1

12510

= 11111012

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 36/63

�Decimal to binary

3.14579

.14579

x 2

0.29158

x 2

0.58316

x 21.16632

x 2

0.33264

x 2

0.66528

x 21.33056

etc.11.001001...

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 37/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 38/63

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 39/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 40/63

�Technique� Convert each hexadecimal digit to a 4-bit equivalent

binary representation

10AF16

= ?2

1 0 A  F

0001 0000 1010 1111

10AF16

= 00010000101011112

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 41/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 42/63

�Technique� Divide by 8

� Keep track of the remainder

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 43/63

123410

=

?8

8 1234

154 28

19 28

2 38

0 2

123410

= 23228

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 44/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 45/63

�Technique

� Divide by 16

� Keep track of the remainder

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 46/63

123410 = ?16

123410

= 4D216

16 1234

77 216

4 13 = D16

0 4

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 47/63

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 48/63

�Technique

� Group bits in threes, starting on right

� Convert to octal digits

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 49/63

10110101112 = ?8

1 011 010 111

1 3 2 7

10110101112= 1327

8

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 50/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 51/63

�Technique

� Group bits in fours, starting on right

� Convert to hexadecimal digits

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 52/63

10101110112 = ?16

10 1011 1011

2 B  B

10101110112= 2BB

16

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 53/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 54/63

�Technique

� Use binary as an intermediary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 55/63

10768 = ?16

1 0 7 6

001 000 111 110

2 3 E

Make a group of 4 bit

From right side &

assign decimal digit to

this group of 4 bit

10768= 23E

16

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 56/63

Hexadecimal

Decimal Octal

Binary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 57/63

�Technique

� Use binary as an intermediary

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 58/63

1F0C16 = ?8

1 F 0 C

0001 1111 0000 1100

1 7 4 1 4

1F0C16

= 174148

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 59/63

Don¶t use a calculator!

Decimal Binary Octal

Hexa-

decimal

33

1110101

703

1AF

Skip answer   Answer 

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 60/63

Decimal Binary Octal

Hexa-decimal

33 100001 41 21

117 1110101 165 75451 111000011 703 1C3

431 110101111 657 1AF

 Answer 

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 61/63

� Base 10Power  Preface ol

10-12  pico  p

10-9 nano n

10-6 icr o Q

10-3 illi

103 kilo k 

106

ega M

109 giga G

1012 tera T

Val e

.000000000001

.000000001

.000001

.001

1000

1000000

1000000000

1000000000000

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 62/63

� Base 2Power  Preface ol

210 kilo k 

220 ega M

230 Giga G

Val e

1024

1048576

1073741824

� What is the value of ³k´, ³M´, and ³G´?

� In computing, particularly w.r.t. memory,the base-2 interpretation generally applies

8/6/2019 Module 1 _ Number System

http://slidepdf.com/reader/full/module-1-number-system 63/63

/ 230 =

In the lab«

1. Double click on My Computer 2. Right click on C:

3. Click on Properties