40
Chapter 3 Chapter 3 Number System and Number System and Codes Codes

Chapter 3 Number System and Codes. Decimal and Binary Numbers

  • View
    274

  • Download
    5

Embed Size (px)

Citation preview

Page 1: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Chapter 3Chapter 3

Number System and Number System and CodesCodes

Page 2: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Decimal and Binary Decimal and Binary NumbersNumbers

Page 3: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Decimal and Binary Decimal and Binary NumbersNumbers

Page 4: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Converting Decimal to Converting Decimal to BinaryBinary

1.Sum of powers of 2

Page 5: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Converting Decimal to Converting Decimal to BinaryBinary

1.Repeated Division

Page 6: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Binary Numbers and Binary Numbers and ComputersComputers

Page 7: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Hexadecimal NumbersHexadecimal Numbers

Page 8: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Converting decimal to Converting decimal to hexadecimalhexadecimal

Page 9: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Converting binary to Converting binary to hexadecimalhexadecimal

Converting hexadecimal to Converting hexadecimal to binarybinary??

Page 10: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Hexadecimal numbersHexadecimal numbers

Page 11: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Binary arithmeticBinary arithmetic

Binary additionBinary addition

Page 12: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Representing Integers with Representing Integers with binarybinary

Some of challenges:-Some of challenges:- Integers can be positive or negativeIntegers can be positive or negative Each integer should have a unique Each integer should have a unique

representationrepresentation The addition and subtraction should be The addition and subtraction should be

efficient.efficient.

Page 13: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Representing a positive Representing a positive numbersnumbers

Page 14: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Representing a negative Representing a negative numbers using Sign-numbers using Sign-Magnitude notationMagnitude notation

-5 = 1101 4-bits sign-manitude-55 =10110111 8-bits sign-

magnitude

Page 15: Chapter 3 Number System and Codes. Decimal and Binary Numbers

11’’s Complements Complement

The 1’s complement representation The 1’s complement representation of the positive number is the same of the positive number is the same as sign-magnitude.as sign-magnitude. +84 = 01010100+84 = 01010100

Page 16: Chapter 3 Number System and Codes. Decimal and Binary Numbers

11’’s Complements Complement

The 1’s complement representation The 1’s complement representation of the negative number uses the of the negative number uses the following rule:-following rule:- Subtract the magnitude from 2Subtract the magnitude from 2nn-1-1

For example:For example: -36 = ???-36 = ???

+36 = 0010 0100+36 = 0010 0100

Page 17: Chapter 3 Number System and Codes. Decimal and Binary Numbers

11’’s Complements Complement

Example :-Example :- - 57- 57

+57 = 0011 1001+57 = 0011 1001 -57 = 1100 0110-57 = 1100 0110

Page 18: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Converting to decimal Converting to decimal formatformat

Page 19: Chapter 3 Number System and Codes. Decimal and Binary Numbers

22’’s Complements Complement

For negative numbers:-

Subtract the magnitude from 2n. Or

Add 1 to the 1’s complement

Page 20: Chapter 3 Number System and Codes. Decimal and Binary Numbers

ExampleExample

Page 21: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Convert to decimal valueConvert to decimal value

Positive values:- Positive values:- 0101 1001 = +890101 1001 = +89

Negative valuesNegative values

Page 22: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Two's Complement Arithmetic

Page 23: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Adding Positive Integers in 2's Complement Form

Overflow in Binary Addition

Page 24: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Overflow in Binary Addition

Page 25: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Overflow in Binary Addition

Page 26: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Overflow in Binary Addition

Page 27: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Adding Positive and Negative Integers in 2's

ComplementForm

Page 28: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Adding Positive and Negative Integers in 2's

ComplementForm

Page 29: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Subtraction of Positive and Negative Integers

Page 30: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Digital Codes

Binary Coded Decimal (BCD)

Page 31: Chapter 3 Number System and Codes. Decimal and Binary Numbers

BCD

Page 32: Chapter 3 Number System and Codes. Decimal and Binary Numbers

BCD

Page 33: Chapter 3 Number System and Codes. Decimal and Binary Numbers

4221 Code

Page 34: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Gray Code

In pure binary coding or 8421 BCD then counting from 7 (0111) to 8 (1000) requires 4 bits to be changed simultaneously.

Gray coding avoids this since only one bit changes between subsequent numbers

Page 35: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Binary –to-Gray Code Conversion

Page 36: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Gray –to-Binary Conversion

Page 37: Chapter 3 Number System and Codes. Decimal and Binary Numbers

Gray –to-Binary Conversion

Page 38: Chapter 3 Number System and Codes. Decimal and Binary Numbers

The Excess-3- Code

Page 39: Chapter 3 Number System and Codes. Decimal and Binary Numbers

ParityParity

The method of parity is widely used as The method of parity is widely used as a method of error detection.a method of error detection. Extar bit known as parity is added to data Extar bit known as parity is added to data

wordword The new data word is then transmitted.The new data word is then transmitted.

Two systems are used:Two systems are used: Even parity: the number of 1’s must be Even parity: the number of 1’s must be

even.even. Odd parity: the number of 1’s must be odd.Odd parity: the number of 1’s must be odd.

Page 40: Chapter 3 Number System and Codes. Decimal and Binary Numbers

ParityParity

Example:Example:

Even Even ParityParity

Odd Odd parityparity

11001110011110011110010110010

11110111100111100111101111101

11000110000110000110001110001