Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh.

Similar presentations


Presentation on theme: "CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh."— Presentation transcript:

1 CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh

2 2 Number System  Numeric value is represented by a series of digits Number of digits used is fixed by radix Digits multiplied by a power of the radix Digit order determines radix powers “P ositional Number System”  Very large numbers can be represented.  Can also represent fractional values. Created by: Ms.Amany AlSaleh

3 3 Decimal Number System (Cont.)  Review the decimal number system. Base (Radix) is 10 - symbols (0,1,.. 9) Digits For Numbers > 9, add more significant digits in position to the left, e.g. 19>9. Each position carries a weight. Weights: MSD LSD If we were to write 1936.25 using a power series expansion and base 10 arithmetic: 10 -1 10 -2 10 -3 10 3 10 2 10 1 10 0 Created by: Ms.Amany AlSaleh

4 4 Decimal Number System (Cont.)  How many items does a decimal number represent? 8653 = 8x10 3 + 6x10 2 + 5x10 1 + 3x10 0  What about fractions? 97654.35 = 9x10 4 + 7x10 3 + 6x10 2 + 5x10 1 + 4x10 0 + 3x10 -1 + 5x10 -2 In formal notation -> (97654.35) 10  Why do we use 10 digits, anyway? Created by: Ms.Amany AlSaleh

5 5 Positional Integer Number Values  Given a digit series of  The full expression for the represented value is Created by: Ms.Amany AlSaleh

6 6 Positional Fractional Number Values  Given a digit series of  The full expression for the represented value is Created by: Ms.Amany AlSaleh

7 7 General Format for Decimal Numbers  The full expression for the represented value is  Each coefficient A i is one of 10 digits (0,1,2,3,4,5,6,7,8,9).  Coefficients are multiplied by powers of 10.  The subscript value i gives the weight 10i by which the coefficient is multiplied.  The decimal number system is said to be of base or radix 10.  In general any number with base/radix r is represented by the above string of coefficients where: 0 ≤  A i < r and. is the radix point.  A n-1 is referred to as most significant digit (MSD) and A -m as the least significant digit (LSD). Created by: Ms.Amany AlSaleh

8 8 Binary Number System  Just like decimal numbers except: The only valid digits are 0 and 1 The base is 2 instead of 10  Strings of binary digits (“bits”) One bit can store a number from 0 to 1 n bits can store numbers from 0 to 2 n -1  Examples 0000 0001 1001010101000 Created by: Ms.Amany AlSaleh

9 9 Binary to Decimal Conversion  Binary to decimal conversion is just the explicit expression of the positional values (both integral and fractional parts).  Positional representation: Each digit represents a power of 2 So (101) 2 binary is 1 2 2 + 0 2 1 + 1 2 0 or 1 4 + 0 2 + 1 1 = 5  Easy, just multiply digit by power of 2.  Just like a decimal number is represented. 1 0 1 1 x 2 0 = 1 0 x 2 1 = 0 1 x 2 2 = 4 Total = 5 Created by: Ms.Amany AlSaleh

10 10 Binary to Decimal Conversion(Cont.) 76543210 2727 2626 2525 2424 23232 2121 2020 1286432168421 100 1 1 1 0 0 128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156 What is 10011100 in decimal? 76543210 position number Created by: Ms.Amany AlSaleh

11 11 Binary to Decimal Conversion(Cont.)  (4021.2) 5 =  (1001) 2 =  (110000.0111) 2 = ( ? ) 10 4 * 5 3 + 0 * 5 2 + 2 * 5 1 + 1 * 5 0 + 2 * 5 -1 = 500 + 0 + 10 + 1 + 0.4 = (511.4) 10 1 * 2 3 + 0 * 2 2 + 0 * 2 1 + 1 * 2 0 = 8 + 0 + 0 + 1 = (9) 10 ANS: 48.4375 Created by: Ms.Amany AlSaleh

12 12 Special Powers of 2 In computer work we use the following abbreviations:  2 10 (1024) is Kilo, denoted "K"  2 20 (1,048,576) is Mega, denoted "M"  2 30 (1,073, 741,824) is Giga, denoted "G“  2 40 (1,099,511,627,776) is Tera, denoted “T“  Examples 4K= ? 16M= ? 2 2 x 2 10 = 2 12 = 4096 2 4 x 2 20 = 2 24 = 16,777,216 Created by: Ms.Amany AlSaleh

13 13 Special Powers of 2 (Cont.) Think about this:  What is the exact number of bytes in a 16 GB memory module?  16 GB = 2 4 x 2 30 = 2 34 = 17,179,869,184 Bytes Note: Refer to table 1-2 page 15 in your text book for more powers of 2. Created by: Ms.Amany AlSaleh

14 14 The Growth of Binary Numbers n2n2n 02 0 =1 1 2 1 =2 2 2 2 =4 3 2 3 =8 4 2 4 =16 5 2 5 =32 6 2 6 =64 72 7 =128 n2n2n 82 8 =256 9 2 9 =512 10 2 10 =1024 11 2 11 =2048 12 2 12 =4096 20 2 20 =1M 30 2 30 =1G 402 40 =1T Mega Giga Tera Created by: Ms.Amany AlSaleh

15 15 Number Systems – Examples GeneralDecimalBinary Radix (Base)r102 Digits0 => r - 10 => 90 => 1 0 1 2 3 Powers of 4 Radix 5 -2 -3 -4 -5 r 0 r 1 r 2 r 3 r 4 r 5 r -1 r -2 r -3 r -4 r -5 1 10 100 1000 10,000 100,000 0.1 0.01 0.001 0.0001 0.00001 1 2 4 8 16 32 0.5 0.25 0.125 0.0625 0.03125 Created by: Ms.Amany AlSaleh

16 16 Conversion Between Bases  To convert from one base to another 1) Convert the Integer Part 2) Convert the Fraction Part 3) Join the two results with a radix point Created by: Ms.Amany AlSaleh

17 17 Decimal to Binary Conversion  To Convert the Integral Part: Repeatedly divide the number by the new radix and save the remainders. The digits for the new radix are the remainders in reverse order of their computation. If the new radix is > 10, then convert all remainders > 10 to digits A, B, …  To Convert the Fractional Part: Repeatedly multiply the fraction by the new radix and save the integer digits that result. The digits for the new radix are the integer digits in order of their computation. If the new radix is > 10, then convert all integers > 10 to digits A, B, … Created by: Ms.Amany AlSaleh

18 18 Example : Convert 46.6875 10 To Base 2  Convert 46 to Base 2  Convert 0.6875 to Base 2:  Join the results together with the radix point. Created by: Ms.Amany AlSaleh

19 19 Example : Convert 46.6875 10 To Base 2 46/2 = 23 rem = 0 23/2 = 11 + 1 / 2 rem = 1 11/2 = 5 + 1 / 2 rem = 1 5/2 = 2 + 1 / 2 rem = 1 2/2 = 1 rem = 0 1/2 = 0 + 1 /2 rem = 1 (46) 10  (101110) 2 MSD LSD Created by: Ms.Amany AlSaleh

20 20 Example : Convert 46. 6875 10 To Base 2 0.6875 x 2 = 1.3750 integer = 1 0.3750 x 2 = 0.7500 integer = 0 0.7500 x 2 = 1.5000 integer = 1 0.5000 x 2 = 1.0000 integer = 1 (0.6875) 10 = (0.1011) 2 MSD LSD Created by: Ms.Amany AlSaleh

21 21 Checking the Conversion  If you’re not sure of the results, convert back to decimal to check yourself!  From the prior conversion of 46.6875 10 101110 2 = 1·32 + 0·16 +1·8 +1·4 + 1·2 +0·1 = 32 + 8 + 4 + 2 = 46 0.1011 2 = 1/2 + 0 + 1/8 + 1/16 = 0.5000 + 0.1250 + 0.0625 = 0.6875 Created by: Ms.Amany AlSaleh

22 22 Decimal to Binary Conversion Convert an Integer from Decimal to Another Base: For each digit position: Divide decimal number by the base (e.g. 2); keep track of remainder. Repeat with dividend = last quotient until zero First remainder is binary LSB, last is the MSB Integer Quotient 13/2 = 6 + ½ a 0 = 1 6/2 = 3 + 0 a 1 = 0 3/2 = 1 + ½ a 2 = 1 1/2 = 0 + ½ a 3 = 1 RemainderCoefficient Answer (13) 10 = (a 3 a 2 a 1 a 0 ) 2 = (1101) 2 Example for (13) 10 : Created by: Ms.Amany AlSaleh

23 23 Decimal to Binary Conversion (Cont.) Convert an Fraction from Decimal to Another Base For each digit position: Multiply fraction by the base (two); keep track of integer part Repeat with multiplier = last product fraction First integer is MSB, last is the LSB Repeat until fraction becomes zero or conversion may not be exact; a repeated fraction Example for (0.625) 10 : Integer 0.625 x 2 = 1 + 0.25 a -1 = 1 0.250 x 2 = 0 + 0.50 a -2 = 0 0.500 x 2 = 1 + 0 a -3 = 1 FractionCoefficient Answer (0.625) 10 = (0.a -1 a -2 a -3 ) 2 = (0.101) 2 Created by: Ms.Amany AlSaleh

24 24 Decimal to Binary Conversion (Cont.)  Find the binary equivalent of 37. MSB LSB = 18 + 0.5 = 9 + 0 = 4 + 0.5 = 2 + 0 = 1 + 0 = 0 + 0.5 1 0 1 0 0 1 37 2 18 9 4 2 1 0 2 2 2 2 2 (37) 10 = (100101) 2 Created by: Ms.Amany AlSaleh

25 25 Decimal to Binary Conversion (Cont.)  Find the binary equivalent of 53. MSB LSB = 26 + 0.5 = 13 + 0 = 6 + 0.5 = 3 + 0 = 1 + 0.5 = 0 + 0.5 53 2 53 10 = 110101 2 1 0 1 0 1 1 26 13 6 3 1 0 2 2 2 2 2 Created by: Ms.Amany AlSaleh

26 26 Decimal to Binary Conversion (Cont.)  Convert (0.8542) 10 to binary (give answer to 6 digits). 0.8542 x 2 = 1 + 0.7084 a -1 = 1 0.7084 x 2 = 1 + 0.4168 a -2 = 1 0.4168 x 2 = 0 + 0.8336 a -3 = 0 0.8336 x 2 = 1 + 0.6672 a -4 = 1 0.6675 x 2 = 1 + 0.3344 a -5 = 1 0.3344 x 2 = 0 + 0.6688 a -6 = 0 (53.8542) 10 = (110101.110110) 2 (0.8542) 10 = (0. a 1 a 2 a 3 a 4 a 5 a 6 ) 2 = (0.110110) 2 Created by: Ms.Amany AlSaleh

27 27 Octal and Hexadecimal Numbers  Both are positional systems with different radix and digits.  Useful for representing binary numbers indirectly because their bases are powers of two. Octal: Radix/ base = 8 Digits = 0,1,2,3,4,5,6,7 Each octal digit corresponds to three binary digits. (2 3 =8) Less convenient than hexadecimal for use with 8-bit bytes Hexadecimal: Radix/ base = 16 Digits = 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Each hexadecimal digit corresponds to four binary digits. (2 4 =16)  Primary advantage: Strings of 0’s and 1’s are too hard to write  More compact representation  More convenient  Easy to convert to/from binary. Created by: Ms.Amany AlSaleh

28 28 Octal and Hexadecimal Numbers (Cont.)  Octal Numbers DecBinOctal 000000 100011 200102 300113 401004 501015 601106 701117 Created by: Ms.Amany AlSaleh

29 29 Octal and Hexadecimal Numbers (Cont.)  Hexadecimal Numbers DecBinHex 000000 100011 200102 300113 401004 501015 601106 701117 DecBinHex 810008 910019 101010? 111011? 121100? 131101? 141110? 151111? Created by: Ms.Amany AlSaleh

30 30 Octal and Hexadecimal Numbers (Cont.)  Hexadecimal Numbers: Letters to represent 10-15 DecBinHex 000000 100011 200102 300113 401004 501015 601106 701117 DecBinHex 810008 910019 101010A 111011B 121100C 131101D 141110E 151111F Created by: Ms.Amany AlSaleh

31 31 Numbers in Different Bases  Check this table for different conversion schemes. Created by: Ms.Amany AlSaleh

32 32 Octal and Hexadecimal Conversions  The following conversions will be discussed: 1.Octal/Hex to decimal: the same technique with a radix of 8 or 16 instead of 2. 1.Octal to decimal 2.Hex to decimal 2.Decimal to Octal/Hex: the same technique with a radix of 8 or 16 instead of 2. 1.Decimal to octal 2.Decimal to hex 3.Octal/Hex to binary. 1.Octal to binary 2.Hex to binary 4.Binary to octal/ hex. 1.Binary to octal 2.Binary to hex Created by: Ms.Amany AlSaleh

33 33 1.1 Octal to Decimal 1.1 Octal to decimal:  Expand the number in a power series with a base of 8.  Examples: (76) 8 = (?) 10 (76) 8 = 7 x 8 1 + 6 x 8 0 = 56 + 6 = (62) 10 (127.4) 8 = (?) 10 (127.4) 8 = 1 x 8 2 + 2 x 8 1 + 7 x 8 0 + 4 x 8 -1 = (87.5) 10 (236.4) 8 = (?) 10 (236.4) 8 = 2 x 8 2 + 3 x 8 1 + 6 x 8 0 + 4 x 8 -1 = (158.5) 10 Created by: Ms.Amany AlSaleh

34 34 1.2 Hex to Decimal 1.2 Hex to decimal:  Expand the number in a power series with a base of 16.  Examples: (AC12) 16 = (?) 10 = 10 x 16 3 + 12 x16 2 + 1 x 16 1 + 2 x 16 0 = 40960 + 3072 + 16 + 2 = (44050) 10 (D63FA) 16 = (?) 10 = 13 x 16 4 + 6 x 16 3 + 3 x16 2 + 15 x 16 1 + 10 x 16 0 = (877562) 10 Created by: Ms.Amany AlSaleh

35 35 2.1 Decimal to Octal 2.1 Convert an Integer from Decimal to Octal For each digit position: Divide decimal number by the base (8) The remainder is the lowest-order digit Repeat first two steps until no divisor remains. Example for (175) 10: Integer Quotient 175/8 = 21 + 7/8 a 0 = 7 21/8 = 2 + 5/8 a 1 = 5 2/8 = 0 + 2/8 a 2 = 2 RemainderCoefficient Answer (175) 10 = (a 2 a 1 a 0 ) 2 = (257) 8 Created by: Ms.Amany AlSaleh

36 36 2.1 Decimal to Octal (Cont.) 2.1 Convert a Fraction from Decimal to Octal For each digit position: Multiply decimal number by the base (e.g. 8) The integer is the highest-order digit Repeat first two steps until fraction becomes zero. Example for (0.3125) 10: Integer 0.3125 x 8 = 2 + 0.5 a -1 = 2 0.5000 x 8 = 4 + 0.0 a -2 = 4 FractionCoefficient Answer (0.3125) 10 = (0.24) 8 Created by: Ms.Amany AlSaleh

37 37 2.1 Decimal to Octal (Cont.)  Convert 1122 to octal. = 140 + 0.25 = 17 + 0.5 = 2 + 0.125 = 0 + 0.25 2 4 1 2 1122 8 140 17 2 0 8 8 8 MSB LSB (1122) 10 = (2142) 8 Created by: Ms.Amany AlSaleh

38 38 2.1 Decimal to Octal (Cont.)  Convert (0.3152) 10 to octal (give answer to 4 digits). 0.3152 x 8 = 2 + 0.5216 a-1 = 2 0.5216 x 8 = 4 + 0.1728 a-2 = 4 0.1728 x 8 = 1 + 0.3824 a-3 = 1 0.3824 x 8 = 3 + 0.0592 a-4 = 3 (0.3152) 10 = (0.2413) 8 Created by: Ms.Amany AlSaleh

39 39 2.2 Decimal to Hex  Analogous to decimal  binary.  Convert (333) 10 to Hexadecimal MSB LSB = 20 + 0.8125 = 1 + 0.25 = 0 + 0.0625 13=D 4 1 333 20 1 0 16 (333) 10 = (14D) 16 16 Created by: Ms.Amany AlSaleh

40 40 2.2 Decimal to Hex (Cont.)  Convert (684) 10 to Hexadecimal MSB LSB = 42 + 0.75 = 2 + 0.625 = 0 + 0.125 12=C 10=A 2 684 42 2 0 16 (684) 10 = (2AC) 16 16 Created by: Ms.Amany AlSaleh

41 41 3. Octal/Hex to Binary 3.1 Octal to Binary: Expand each octal digit into its equivalent 3 bit binary value. 3.2 Hex to Binary: Expand each hex digit into its equivalent 4 bit binary value. Created by: Ms.Amany AlSaleh

42 42 3.1 Octal to Binary  Octal to Binary Convert/expand each octal digit to a 3-bit binary equivalent. Extra 0’s are deleted. ( 3 5 4. 7 4 ( 3 5 4. 7 4 ) 8 = (011 101 100. 111100) 2 011101100 111100 = (11 101 100. 1111) 2 Created by: Ms.Amany AlSaleh

43 43 3.2 Hex to Binary  Hex to Binary Convert/expand each octal digit to a 4-bit binary equivalent. Extra 0’s are deleted. (2AC (2AC) 16 001010101100 (A3E (A3E) 16 101000111110 = (0010 1010 1100) 2 = (101000111110) 2 = (10 1010 1100) 2 Created by: Ms.Amany AlSaleh

44 44 4. Binary to Octal/Hex  To convert from binary to octal/ hex: Starting at radix point, go left/right and group bits into groups of 3 or 4 bits / group. Note: 0’s should be added on the left of the string of bits to the left of the binary point and on the right of string of bits to the right of the binary points to make the number of bits a multiple of 3/4 and get a correct octal/hexadecimal result. Convert each bit group into equivalent octal or hex digit. Created by: Ms.Amany AlSaleh

45 45 4.1 Binary to Octal  Binary to Octal Starting at radix point, go left/right and group bits into groups of 3 bits / group Convert each bit group into equivalent octal digit 10110001101011.11110000011 (10110001101011.111100000110) 2 = (26153.7406) 8 2 010 10016110 110 6.. 510130117111 41000000 Created by: Ms.Amany AlSaleh

46 46 4.2 Binary to Hex  Binary to Hex Starting at radix point, go left/right and group bits into groups of 4 bits / group Convert each bit group into equivalent hex digit 101001101111011.101011011B (101001101111011.10101) 2 = (537B.A8) 16 5 0101 7011130011 1010A 1000 8.. Created by: Ms.Amany AlSaleh

47 47 Conversion Examples  Octal, Hex Conversion Examples 0100111010111010.01100010101100101000 4 E B A. 6 2 B 2 8 4 7 2 7 2. 3 0 5 3 1 2 (010 111 100. 001 011 000) 2 = (?) 8 = (274.130) 8 (0110 1111 1101. 0001 0011 0100) 2 = (?) 16 = (6FD.134) 16 From table Created by: Ms.Amany AlSaleh

48 48 Octal to Hexadecimal via Binary  Convert octal to binary.  Use groups of four bits and convert as above to hexadecimal digits. “Octal to Binary to Hexadecimal”  Example: ( 635.17 ) 8 = ( ? ) 16 ( 6 3 5. 1 7 ) 8 (110 011 101. 001 111 ) 2 (0001)(1001)(1101).(0011)(1100) ( 1 9 D. 3 C ) 16 Octal  Binary Binary  Hex Created by: Ms.Amany AlSaleh

49 49 Number Ranges  Consider a 2-digit counter.  What is the minimum number it can show?  What is the maximum number it can show?  What is its number range? 62 position Each position has 10 possibilities: 0,1,2,3,4,5,6,7,8,9. 10 * 10 = 10 2 Radix # Positions 00 99 Range: 0  99 0  (10 2 -1) Created by: Ms.Amany AlSaleh

50 50 Number Ranges (Cont.)  Consider a 3-digit counter.  What is the minimum number it can show?  What is the maximum number it can show?  What is its number range? 624 position Each position has 10 possibilities: 0,1,2,3,4,5,6,7,8,9. 10 * 10 * 10 = 10 3 Radix # Positions 000 999 Range: 0  999 0  (10 3 -1) Created by: Ms.Amany AlSaleh

51 51 Number Ranges (Cont.)  What if the counter was a 3-bit binary counter?  What is the minimum number it can show?  What is the maximum number it can show?  What is its number range? 010 position Each position has 2 possibilities: 0,1. 2 * 2 * 2 = 2 3 Radix # Positions (bits) (000) 2 (111) 2 = 7 10 Range: 0  7 0  (2 3 -1) Created by: Ms.Amany AlSaleh

52 52 Number Ranges (Cont.)  In digital computers, the range of numbers that can be represented is based on the number of bits available in the hardware structure that stores and processes information.  This number is frequently a power of 2, e.g.: 8,16,32,64. Given n digits in radix r, there are r n distinct elements that can be represented. These elements range from 0 to r n -1 Created by: Ms.Amany AlSaleh

53 53 Number Ranges (Cont.)  Number of bits is fixed by the hardware structure:  The addition of leading or trailing zeros to represent numbers might be necessary in some cases.  The range of numbers to be represented is fixed.  For a computer processing 16-bit integers: What is the range of integers that can be handled? 0  2 16 -1 How can the number 26 be represented in this system? 0000 0000 0001 1010 How can the number 0.375 be represented in this system? 0.0110 0000 0000 0000 Created by: Ms.Amany AlSaleh


Download ppt "CS151 Introduction to Digital Design Chapter 1: Digital Systems and Information Lecture 2 1Created by: Ms.Amany AlSaleh."

Similar presentations


Ads by Google