Transcript Chapter 2
Digital Fundamentals CHAPTER 2 Number Systems, Operations, and Codes Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 1 Number Systems Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 2 Decimal Numbers • The decimal number system has ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 • The decimal numbering system has a base of 10 with each position weighted by a factor of 10: Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 3 Binary Numbers • The binary number system has two digits: 0 and 1 • The binary numbering system has a base of 2 with each position weighted by a factor of 2: Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 4 Decimal-to-Binary Conversion Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 5 Decimal-to-Binary Conversion • Sum-of-weights method • Repeated division-by-2 method • Conversion of decimal fractions to binary Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 6 Binary Arithmetic Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 7 Binary Arithmetic • • • • Binary addition Binary subtraction Binary multiplication Binary division Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 8 Complements of Binary Numbers Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 9 Complements of Binary Numbers • 1’s complements • 2’s complements Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 10 Complements of Binary Numbers • 1’s complement Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 11 Complements of Binary Numbers • 2’s complement Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 12 Signed Numbers Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 13 Signed Numbers • • • • • Signed-magnitude form 1’s and 2’s complement form Decimal value of signed numbers Range of values Floating-point numbers Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 14 Signed Numbers • Signed-magnitude form – The sign bit is the left-most bit in a signed binary number – A 0 sign bit indicates a positive magnitude – A 1 sign bit indicates a negative magnitude Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 15 Signed Numbers • 1’s complement form – A negative value is the 1’s complement of the corresponding positive value • 2’s complement form – A negative value is the 2’s complement of the corresponding positive value Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 16 Signed Numbers • Decimal value of signed numbers – Sign-magnitude – 1’s complement – 2’s complement Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 17 Signed Numbers • Range of Values 2’s complement form: – (2n – 1) to + (2n – 1 – 1) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 18 Signed Numbers • Floating-point numbers – Single-precision (32 bits) – Double-precision (64 bits) – Extended-precision (80 bits) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 19 Arithmetic Operations with Signed Numbers • • • • Addition Subtraction Multiplication Division Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 20 Arithmetic Operations with Signed Numbers Addition of Signed Numbers • The parts of an addition function are: – Addend – Augend – Sum Numbers are always added two at a time. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 21 Arithmetic Operations with Signed Numbers Four conditions for adding numbers: • Both numbers are positive. • A positive number that is larger than a negative number. • A negative number that is larger than a positive number. • Both numbers are negative. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 22 Arithmetic Operations with Signed Numbers Signs for Addition • When both numbers are positive, the sum is positive. • When the larger number is positive and the smaller is negative, the sum is positive. The carry is discarded. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 23 Arithmetic Operations with Signed Numbers Signs for Addition • When the larger number is negative and the smaller is positive, the sum is negative (2’s complement form). • When both numbers are negative, the sum is negative (2’s complement form). The carry bit is discarded. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 24 Arithmetic Operations with Signed Numbers Subtraction of Signed Numbers • The parts of a subtraction function are: – Subtrahend – Minuend – Difference Subtraction is addition with the sign of the subtrahend changed. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 25 Arithmetic Operations with Signed Numbers Subtraction • The sign of a positive or negative binary number is changed by taking its 2’s complement • To subtract two signed numbers, take the 2’s complement of the subtrahend and add. Discard any final carry bit. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 26 Arithmetic Operations with Signed Numbers Multiplication of Signed Numbers • The parts of a multiplication function are: – Multiplicand – Multiplier – Product Multiplication is equivalent to adding a number to itself a number of times equal to the multiplier. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 27 Arithmetic Operations with Signed Numbers There are two methods for multiplication: • Direct addition • Partial products The method of partial products is the most commonly used. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 28 Arithmetic Operations with Signed Numbers Multiplication of Signed Numbers • If the signs are the same, the product is positive. • If the signs are different, the product is negative. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 29 Arithmetic Operations with Signed Numbers Division of Signed Numbers • The parts of a division operation are: – Dividend – Divisor – Quotient Division is equivalent to subtracting the divisor from the dividend a number of times equal to the quotient. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 30 Arithmetic Operations with Signed Numbers Division of Signed Numbers • If the signs are the same, the quotient is positive. • If the signs are different, the quotient is negative. Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 31 Hexadecimal Numbers Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 32 Hexadecimal Numbers • Decimal, binary, and hexadecimal numbers Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 33 Hexadecimal Numbers • Binary-to-hexadecimal conversion • Hexadecimal-to-decimal conversion • Decimal-to-hexadecimal conversion Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 34 Hexadecimal Numbers • Binary-to-hexadecimal conversion 1. Break the binary number into 4-bit groups 2. Replace each group with the hexadecimal equivalent Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 35 Hexadecimal Numbers • Hexadecimal-to-decimal conversion 1. Convert the hexadecimal to groups of 4-bit binary 2. Convert the binary to decimal Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 36 Hexadecimal Numbers • Decimal-to-hexadecimal conversion – Repeated division by 16 Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 37 Binary Coded Decimal (BCD) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 38 Binary Coded Decimal (BCD) Decimal and BCD digits Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 39 Digital Codes Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 40 Digital Codes • Gray code • ASCII code Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 41 Digital Codes • Gray code Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 42 Digital Codes • ASCII code (control characters) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 43 Digital Codes • ASCII code (graphic symbols 20h – 3Fh) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 44 Digital Codes • ASCII code (graphic symbols 40h – 5Fh) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 45 Digital Codes • ASCII code (graphic symbols 60h – 7Fh) Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 46 Digital Codes Extended ASCII code (80h – FFh) • Non-English alphabetic characters • Currency symbols • Greek letters • Math symbols • Drawing characters • Bar graphing characters • Shading characters Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 47 Error Detection and Correction Codes Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 48 Error Detection and Correction Codes • Parity error codes • Hamming error codes Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 49 Error Detection and Correction Codes • Parity error codes Floyd Digital Fundamentals, 9/e Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 50 Error Detection and Correction Codes • Hamming error codes – Hamming code words – Hex equivalent of the data bits Floyd Digital Fundamentals, 9/e 0000000 0000111 0011011 0011110 0101010 0101101 0110011 0110100 1001011 1001100 1010010 1010101 1100001 1100110 1111000 1111111 0 1 2 3 4 5 6 7 8 9 A B C D E F Copyright ©2006 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved. Slide 51