Number System - · PDF fileBase or Radix of this number system is 2 (two) ... 8 43 6 8 5 3 5...

29
Number System Madhumita Sengupta Assistant Professor IIIT Kalyani [email protected]

Transcript of Number System - · PDF fileBase or Radix of this number system is 2 (two) ... 8 43 6 8 5 3 5...

Number System

Madhumita Sengupta Assistant Professor

IIIT – Kalyani

[email protected]

COMPUTER FUNDAMENTALS

Fundamentals

Number System

Conversion’s

1’s Complement & 2’s Complement

Binary Codes

Logic Gates

Boolean Algebra

Adder

2

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

NUMBER SYSTEM

Decimal Number System

Binary Number System

Octal Number System

Hexadecimal Number System

3

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL NUMBER SYSTEM

Symbols

Base or Radix - ten

In general,

dn dn-1 dn-2 …. d1 d0 . d-1 d-2 …..d-k

Given by –

(dn x 10 n) + (dn-1 x 10n-1) + (dn-2 x 10n-2)+….+ (d1 x 10 1)

+ (d0 x 100) . (d-1 x 10-1) + (d-2 x 10-2)+…..+(d-k x 10 -k)

Example –

9258.147 = (9 x 103) + (2 x 102) + (5 x 101) + (8 x 100). (1 x 10-1) +

( 4 x 10-2) + (7 x 10-3)

4

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

0 1 2 3 4 5 6 7 8 9

Digits

BINARY NUMBER SYSTEM

Symbols

Base or Radix of this number system is 2 (two)

In general,

dn dn-1 dn-2 …. d1 d0 . d-1 d-2 …..d-k

Its decimal equivalent is –

(dn x 2 n) + (dn-1 x 2n-1) + (dn-2 x 2n-2)+….+ (d1 x 21) + (d0 x 20) . (d-1

x 2-1) + (d-2 x 2-2)+…..+(d-k x 2-k)

Example –

1011.001 = (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20). (0 x 2-1) + ( 0 x

2-2) + (1 x 2-3)

5

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

0 1

Bits

OCTAL NUMBER SYSTEM Symbols

Base or Radix of this number system is 8 (eight)

In general,

dn dn-1 dn-2 …. d1 d0 . d-1 d-2 …..d-k

Its decimal equivalent is –

(dn x 8n) + (dn-1 x 8n-1) + (dn-2 x 8n-2)+….+ (d1 x 81) +

(d0 x 80) . (d-1 x 8-1) + (d-2 x 8-2)+…..+(d-k x 8-k)

Example –

7256.147 = (7 x 83) + (2 x 82) + (5 x 81) + (6 x 80). (1 x 8-1) + ( 4

x 8-2) + (7 x 8-3)

6

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

0 1 2 3 4 5 6 7

HEXADECIMAL NUMBER SYSTEM Symbols

Base or Radix of this number system is 16 (sixteen)

In general,

dn dn-1 dn-2 …. d1 d0 . d-1 d-2 …..d-k

Its decimal equivalent is –

(dn x 16n) + (dn-1 x 16n-1) + (dn-2 x 16n-2)+….+ (d1 x 161) +

(d0 x 160) . (d-1 x 16-1) + (d-2 x 16-2)+…..+(d-k x 16-k)

Example –

92A8.14D = (9 x 163) + (2 x 162) + (10 x 161) + (8 x 160). (1 x 16-1)

+ ( 4 x 16-2) + (13 x 16-3) 7

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

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

10 11 12 13 14 15

CONVERSION Decimal to Binary

Decimal to Octal

Decimal to Hexadecimal

Binary to Decimal

Binary to Octal

Binary to Hexadecimal

Octal to Decimal

Octal to Binary

Octal to Hexadecimal

Hexadecimal to Decimal

Hexadecimal to Binary

Hexadecimal to Octal 8

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL TO BINARY

Convert (39)10

Given function 39

Divide 39 by 2 2 39

2 19 1

2 9 1

2 4 1

2 2 0

2 1 0

1

Result (39)10 = (100111)2

9

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL TO BINARY

Convert (0.75)10

Double-dabble method

Given function 0.75

Multiply 0.75 by 2 1.50

Multiply 0.50 by 2 1.00

Result (0.75)10 = (0.11)2

10

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL TO BINARY (SECOND METHOD )

28 27 26 25 24 23 22 21 20

11

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

256 128 64 32 16 8 4 2 1

0 1

Convert (169)10

Test 256 < 169 True / False

Test 128 < 169 (169-128 = 41 )

Test 64 < 41, 32 <41 (41-32 = 9)

Test 9 < 16, 8 < 9 (9-8=1)

0 1 0 1

0

0 1 0 1 0 1 0 0 1

TEST YOUR KNOWLEDGE

(0.15)10

= (.0010011)2 7 bit fraction

2 * 0.15 = 0.3

2 * 0.3 = 0.6

2 * 0.6 = 1.2

2 * 0.2 = 0.4

2 * 0.4 = 0.8

2 * 0.8 = 1.6

2 * 0.6 = 1.2

12

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL TO OCTAL

13

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (39)10

Given function 39

Divide 39 by 8 8 39

8 4 7

4

Result (39)10 = (47)8

Cross Check

=(4*81) + (7*80)

=(4*8) + (7*1)

DECIMAL TO OCTAL

14

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (350)10

Given function 350

Divide 350 by 8 8 350

8 43 6

8 5 3

5

Result (350)10 = (536)8

= (5 * 82)+(3 * 81)+(6 * 80)

= 320 + 24 + 6

= 350

DECIMAL TO OCTAL

Convert (0.93)10 to Octal

0.93 * 8 7.44

0.44 * 8 3.52

0.52 * 8 4.16

0.16 * 8 1.28

Hence (0.93)10 = (0.7341)8

15

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

DECIMAL TO HEXADECIMAL

16

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (350)10

Given function 350

Divide 350 by 16 16 350

16 21 14

16 1 5

1

Result (350)10 = (15E)16

= (1 * 162)+(5 * 161)+(14 * 160)

= (256) + (80) + 14

= 350

BINARY TO DECIMAL

(10101)2

Step 1

Step 2

Step 3

Result

(10101)2 = (21)10 17

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

1 0 1 0 1

1 x 24 0 x 23 1 x 22 0 x 21 1 x 20

16 0 4 0 1

16 + 4 + 1 = (21)10

B2D CONT...

18

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (11101.001)2 to decimal

Step 1

Step 2

Step 3

Result

(11101.001)2 = (16+8+4+1+0.125)10 = (29.125)10

1 1 1 0 1 . 0 0 1

1 x 24 1 x 23 1 x 22 0 x 21 1 x 20 . 0 x 2-1 0 x 2-2 1 x 2-3

24 23 22 0 20 . 0 0 2-3

16 8 4 0 1 . 0 0 0.125

BINARY TO DECIMAL (SECOND METHOD)

1 0 0 1 0 1 1

1*2+0=2

2*2+0=4

4*2+1=9

9*2+0=18

18*2+1=37

37*2+1 =75

Result (1001011)2 = (75)10

19

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

BINARY TO OCTAL

Convert (110101.101010)2 to Octal

Step 1

Step 2

Step 3

Step 4 Result :- (65.52)8

20

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

1 1 0 1 0 1 . 1 0 1 0 1 0

1 1 0 1 0 1 . 1 0 1 0 1 0

G-2 G-1 G-1 G-2

1 1 0 1 0 1 . 1 0 1 0 1 0

6 5 . 5 2

B2O CONT…

Convert (10101111001.0111)2 to Octal

Step 1

Step 2

Step 3

Step 4 Result :- (2571.34)8

21

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

1 0 1 0 1 1 1 1 0 0 1 . 0 1 1 1

0 1 0 1 0 1 1 1 1 0 0 1 . 0 1 1 1 0 0

G-4 G-3 G-2 G-1 . G-1 G-2

0 1 0 1 0 1 1 1 1 0 0 1 . 0 1 1 1 0 0

2 5 7 1 . 3 4

BINARY TO HEXADECIMAL Convert (110101.101010)2 to Hexadecimal

Step 1

Step 2

Step 3

Step 4 Result :- (35.A8)16

22

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

1 1 0 1 0 1 . 1 0 1 0 1 0

0 0 1 1 0 1 0 1 . 1 0 1 0 1 0 0 0

G2 G1 G1 G2

0 0 1 1 0 1 0 1 . 1 0 1 0 1 0 0 0

3 5 . A 8

OCTAL TO DECIMAL

Convert (4057.06)8 to Decimal

= 4 * 83 + 0 * 82 + 5 * 81 + 7 * 80 + 0 * 8-1 + 6 * 8-2

= 2048 + 0 + 40 + 7 + 0 +0.0937 = (2095.0937)10

23

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

OCTAL TO BINARY Convert (4057.06)8 to Binary

Step 1

Step 2

Result

(4057.06)8 = (100000101111.000110)2

24

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

4 0 5 7 . 0 6

1 0 0 0 0 0 1 0 1 1 1 1 . 0 0 0 1 1 0

4 0 5 7 . 0 6

OCTAL TO HEXADECIMAL

25

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (4057.06)8 to Hexadecimal

Step 1 : Group three bit

Step 2 : place the bits

Step 3 : Group 4 bit each and place digit

Result

(4057.06)8 = (82F.18)16

4 0 5 7 . 0 6

1 0 0 0 0 0 1 0 1 1 1 1 . 0 0 0 1 1 0

4 0 5 7 . 0 6

1 0 0 0 0 0 1 0 1 1 1 1 . 0 0 0 1 1 0 0 0

8 2 15 . 1 8

HEXADECIMAL TO DECIMAL

?

Self compute

26

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

HEXADECIMAL TO BINARY

27

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

Convert (4057.06)16 to Binary

Step 1

Step 2

Result

(4057.06)8 = (100000001010111.00000110)2

4 0 5 7 . 0 6

0 1 0 0 0 0 0 0 0 1 0 1 0 1 1 1 . 0 0 0 0 0 1 1 0

4 0 5 7 . 0 6

HEXADECIMAL TO OCTAL

?

28

ma

dh

um

ita.sn

gp

t@gm

ail.co

m

THE END

29

ma

dh

um

ita.sn

gp

t@gm

ail.co

m