24
Microprocessors Programming and Interfacing ES C 263 Number systems

L1 Number Systems

Embed Size (px)

Citation preview

Page 1: L1 Number Systems

Microprocessors Programming and InterfacingES C 263

Number systems

Page 2: L1 Number Systems

Structure• Number systems• Decimal• Binary• Hexa Decimal• Operations• BCD Codes

Page 3: L1 Number Systems

Number Systems

Decimal (0,1,2,3,4,5,6,7,8,9) Octal (0,1,2,3,4,5,6,7) Hexadecimal (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) Binary (0,1)“A number anan-1a2a1a0a-1a-m expressed in base-r system,

has coefficients multiplied by powers of r “

an.rn+an-1.rn-1+………….+a2.r2+a1.r1+a0.r0+a-1.r-1+a-

2.r-2+……a-m.r-m

Page 4: L1 Number Systems

Convert to decimal

(B65F)16 = 11 X 163 + 6 X 162 + 5 X 161 +15 = (46687)10

(4021.2)5=4 X 53 + 0 X 52 + 2 X 51 + 1 X 50 + 2 X 51 = (511.4)10

(1010.011)2 = 23 + 21 + 2-2 + 2-3 = (10.375)10

Page 5: L1 Number Systems

Binary <-> Octal and Hexadecimal

(10 1100 0110 1011 . 1111 0010 )2 = (2C6B.F2)16

(10 110 001 101 011 . 111 100 000 110)2 = (26153.7460)8

Page 6: L1 Number Systems

Repeated division steps: Divide the decimal number by 2 Write the remainder after each

division until a quotient of zero is obtained.

The first remainder is the LSB and the last is the MSB

Decimal to Binary

Page 7: L1 Number Systems

Decimal to binary..

10

Convert (153)10 to Octal

0

5 0

41

20 1

1 0

2 1

Ans=101001

Integer ReminderConvert (41)10 to binary

2 3

0 2

15319 1

Ans=(231)8

0 1

Page 8: L1 Number Systems

Decimal to hexadecimal

0 E

227

14 3

Ans=0xE3H

Integer ReminderConvert (227)10 to Hexadecimal

Page 9: L1 Number Systems

Decimal fractions to octal

0.513 X 8= 4.104

0.104 X 8= 0.832

0.832 X 8= 6.656

0.656 X 8= 5.248

0.248 X 8= 1.984

0.984 X 8= 7.872

(0.513)10= (0.406517..)8

Convert (0.513)10to octal

4 0 6 5 1 7

Page 10: L1 Number Systems

Two types namely radix and diminished radix complement• Diminished Radix or (r-1)’s complement : For a number N

with n digits, it is defined as (rn-1)-N• Radix or r’s complement : For a number N with n digits, it is

defined as (rn-1)-N+1

Complements

9’s complement of 546700 is (999999-546700)=4532999’s complement of 012398 is (999999-012398)=987601

10’s complement of 012398 is 98760210’s complement of 246700 is 753300

Page 11: L1 Number Systems

1’s and 2’s complement

1’s complement of 1011000 is

2’s complement of 1101011 is

0100111

10100101’s complement of 0101101 is

0010101

2’s complement of 0110111 is 1001001

Page 12: L1 Number Systems

Signed Binary Numbers

Signed magnitude of +7 00000111

Signed magnitude of -7 10000111

Represent +7 in 2’s complement form

Place 0 in sign bit 0

Place magnitude in remaining 7 bits 00000111

Represent -7 in 2’s complement form

Start with 8 bit code for +7 00000111

Invert each bit including the MSB 11111000

Add 1 11111001

Page 13: L1 Number Systems

Signed binary numbers

Get the magnitude of -7

Its 2’s complement is 11111001

MSB is 1. So magnitude is in 2’s complement.Invert all bits including sign. 00000110

Add 1 00000111

Page 14: L1 Number Systems

Range of numbers in sign magnitude

Signed binary Decimal

01111111 +127

------

00000001 +1

00000000 Zero

11111111 -1

-------

10000001 -127

10000000 -128

Page 15: L1 Number Systems

Addition

+13 00001101

+9 00001001

+22 00100110

+13 00001101

-9 11110111

+4 000001001

Ignore carry

+9 00001001

-13 11110011

-4 11111100

-9 11110111

-13 11110011

-22 11101010

Page 16: L1 Number Systems

Hexa decimal addition

7A 0111

3F

1010

0011 1111

B9 1011 1001

7 A

3 F

1110 2510

B16 916

1 Carry

B16 916

Page 17: L1 Number Systems

• Each decimal digit is represented using 4 bits.• Ex: convert 87410 to BCD:

8 7 4 0100 0111 0100 = 010001110100BCD

• Reverse the process to convert BCD to decimal

BCD code

Page 18: L1 Number Systems

Other binary codes

Page 19: L1 Number Systems

Binary Gray Code000 000001 001010 011011 010100 110101 111110 101111 100

Grey code

Only one bit changes between successive values

Page 20: L1 Number Systems

Grey codes

Angular position Measurement where each segment is assigned a binary number

Drive

Load

Shaft encoder

Page 21: L1 Number Systems

Shaft encoder

Shaft Encoder

Page 22: L1 Number Systems

ASCII – American Standard Code for Information Interchange:

• A binary code for letters, numerals, special characters and control characters.

• Seven bit code: 27 = 128 possible code groups

• 94 Graphic Characters and 34 non printing control characters

Alphanumeric Code

Page 23: L1 Number Systems

Alphanumeric Code

Page 24: L1 Number Systems

THANKS