lecture no. 4

41
Lecture No. 4 Number Systems

Upload: colleen-montgomery

Post on 04-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Lecture No. 4. Number Systems. 32-bit f.p. number (recap). 32-bit Floating point format Sign bit1 Exponent bits8 Mantissa bits23 Exponent represented as Biased 127. Range of f.p. numbers (recap). Largest positive/negative number 2 127 Smallest positive/negative number 2 -126 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture No. 4

Lecture No. 4

Number Systems

Page 2: Lecture No. 4

32-bit f.p. number (recap)

32-bit Floating point format Sign bit 1 Exponent bits 8 Mantissa bits 23 Exponent represented as Biased 127

Page 3: Lecture No. 4

Range of f.p. numbers (recap)

Largest positive/negative number 2127

Smallest positive/negative number 2-126

The number Zero Exponent = 00000000 Mantissa = 000 0000

0000 0000 0000 0000 The number infinite

Exponent = 11111111 Mantissa = 000 0000 0000 0000 0000 0000

Page 4: Lecture No. 4

Arithmetic operations on floating point numbers

Addition Adding mantissas after adjusting exponents

Subtraction Subtracting mantissas after adjusting

exponents Multiplication

Multiplying mantissas and adding exponents Division

Dividing mantissas and subtracting exponents

Page 5: Lecture No. 4

64-bit f.p. number (recap)

64-bit Double-Precision floating Point format Sign bit 1 Exponent bits 11 Mantissa bits 52 Exponent represented as Biased 1023

Page 6: Lecture No. 4

f.p. numbers (recap)

How do systems differentiate between number representations?

Defining and Declaring Data Types.

Page 7: Lecture No. 4

Hexadecimal Numbers (recap)

Hexadecimal Number System Base 16 number system 0 to F Used to represent large binary numbers

Page 8: Lecture No. 4

Counting in Hexadecimal (recap)

Decimal Binary Hexadecimal Decimal Binary Hexadecimal

0 0000 0 8 1000 8

1 0001 1 9 1001 9

2 0010 2 10 1010 A

3 0011 3 11 1011 B

4 0100 4 12 1100 C

5 0101 5 13 1101 D

6 0110 6 14 1110 E

7 0111 7 15 1111 F

Page 9: Lecture No. 4

Binary-Hexadecimal conversion (recap)

Binary to Hexadecimal Conversion 11010110101110010110 1101 0110 1011 1001 0110 D 6 B 9 6

Hexadecimal to Binary Conversion FD13 1111 1101 0001 0011

Page 10: Lecture No. 4

Hexadecimal-decimal conversion (recap)

Hexadecimal to Decimal Conversion Indirect Method

Hexadecimal →Binary → Decimal Sum-of-Weights

Page 11: Lecture No. 4

Decimal-Hexadecimal Conversion (recap)

Decimal to Hexadecimal Conversion Indirect Method

Decimal →Binary → Hexadecimal Repeated Division by 16

Page 12: Lecture No. 4

Hexadecimal Arithmetic (recap)

Hexadecimal Addition Carry generated

Hexadecimal Subtraction Borrow weight 16

Page 13: Lecture No. 4

Octal Number System

Base 8 0, 1, 2, 3, 4, 5, 6, 7 Representing Binary in compact form

11011000001102 = 154068 Not commonly used in the presence of

Hexadecimal Number System

Page 14: Lecture No. 4

Counting in Octal

Octal digit represented by a 3-bit binary Decimal 8 represented by 2-digit Octal

Page 15: Lecture No. 4

Counting in Octal

Decimal Binary Octal

0 000 0

1 001 1

2 010 2

3 011 3

4 100 4

5 101 5

6 110 6

7 111 7

Page 16: Lecture No. 4

Counting in Octal

Decimal Octal Decimal Octal Decimal Octal

8 10 16 20 24 30

9 11 17 21 25 31

10 12 18 22 26 32

11 13 19 23 27 33

12 14 20 24 28 34

13 15 21 25 29 35

14 16 22 26 30 36

15 17 23 27 31 37

Page 17: Lecture No. 4

Binary-Octal Conversion

Binary to Octal Conversion Octal to Binary Conversion

Page 18: Lecture No. 4

Octal-Decimal Conversion

Octal to Decimal Conversion Indirect Method

Octal →Binary → Decimal Sum-of-Weights

Page 19: Lecture No. 4

Decimal-Octal Conversion

Decimal to Octal Conversion Indirect Method

Decimal →Binary → Octal Repeated Division by 8

Page 20: Lecture No. 4

Octal Addition & Subtraction

Octal Addition Carry generated

Octal Subtraction Borrow weight 8

Page 21: Lecture No. 4

Binary to Octal Conversion

011010110101110010110 011 010 110 101 110 010 110 3 2 6 5 6 2 6

1011011101001 1 011 011 101 001 001 011 011 101 001 1 3 3 5 1

Page 22: Lecture No. 4

Octal to Binary Conversion

1726 001 111 010 110

Page 23: Lecture No. 4

Sum-of-Weights

4037

(4 x 83) + (0 x 82) + (3 x 81) + (7 x 80)

(4 x 512) + (0 x 64) + (3 x 8) + (7 x 1)

2048 + 0 + 24 + 7

2079

Page 24: Lecture No. 4

Repeated Division by 8

Number Quotient Remainder

2079 259 7 (O0)

259 32 3 (O1)

8 4 0 (O2)

4 0 4 (O3)

Page 25: Lecture No. 4

Octal Addition

Carry 1

7602

+ 4771

14573

Page 26: Lecture No. 4

Octal Subtraction

Borrow 11

7602

- 4771

2611

Page 27: Lecture No. 4

Excess Code BCD Code Gray Code

Alternate Representations

Page 28: Lecture No. 4

Excess Code

A bias is added to Binary Code Used by floating point numbers

Page 29: Lecture No. 4

Excess-8 Code

Decimal 2’s Comp.

Excess-8 Decimal 2’s Comp.

Excess-8

0 0000 1000 -8 1000 0000

1 0001 1001 -7 1001 0001

2 0010 1010 -6 1010 0010

3 0011 1011 -5 1011 0011

4 0100 1100 -4 1100 0100

5 0101 1101 -3 1101 0101

6 0110 1110 -2 1110 0110

7 0111 1111 -1 1111 0111

Page 30: Lecture No. 4

Binary Code to represent decimal digits 0-9 Used by Decimal Number Displays

BCD (Binary Coded Decimal) Code

Page 31: Lecture No. 4

BCD (Binary Coded Decimal) Code

Decimal BCD Decimal BCD

0 0000 5 0101

1 0001 6 0110

2 0010 7 0111

3 0011 8 1000

4 0100 9 1001

Page 32: Lecture No. 4

BCD Addition

23 0010 001145 0100 010168 0110 1000

23 0010 001149 0100 100172 0110 1100

1100 is illegal BCD number

Page 33: Lecture No. 4

BCD Addition

Add a 0110 (6) to an invalid BCD number Carry added to the most significant BCD digit

23 0010 0011

49 0100 1001

72 0110 1100

0110

0111 0010

Page 34: Lecture No. 4

Gray Code

Binary Code more than 1 bit change Electromechanical applications of digital

systems restrict bit change to 1 Shaft encoders Braking Systems

Un-Weighted Code

Page 35: Lecture No. 4

Gray Code

Decimal Gray Binary

0 000 000

1 001 001

2 011 010

3 010 011

4 110 100

5 111 101

6 101 110

7 100 111

Page 36: Lecture No. 4

Gray Code Application

Binary Gray Code

AB

C

A

CB

Page 37: Lecture No. 4

Alphanumeric Code

Numbers, Characters, Symbols ASCII 7-bit Code American Standard Code for Information

Interchange 10 Numbers (0-9) 26 Lower Case Characters (a-z) 26 Upper Case Characters (A-Z) 32 Control Characters Punctuation and Symbols

Page 38: Lecture No. 4

Alphanumeric Code

Extended ASCII 8-bit Code Additional 128 Graphic characters Unicode 16-bit Code

Page 39: Lecture No. 4

ASCII Code

Numbers 0 to 9 ASCII 0110000 (30h) to 0111001 (39h) Alphabets a to z ASCII 1100001 (61h) to 1111010 (7Ah) Alphabets A to Z ASCII 1000001 (41h) to 1011010 (5Ah) Control Characters ASCII 0000000 (0h) to 0011111 (1Fh)

Page 40: Lecture No. 4

Error Detection

Digital Systems are very Reliable Errors during storage or transmission Parity Bit

Even Parity Odd Parity

Page 41: Lecture No. 4

Odd Parity Error Detection

Original data 10011010 With Odd Parity 110011010 1-bit error 110111010 Number of 1s even indicates 1-bit error 2-bit error 110110010 Number of 1s odd no error indicated 3-bit error 100110010 Number of 1s even indicates error