Notes - Unit 4

Notes - Unit 4

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall 2016 Notes - Unit 4 UNSIGNED INTEGER NUMBERS DECIMAL NUMBER SYSTEM DIGIT . A decimal digit can take values from 0 to 9: 0 1 2 3 4 5 6 7 8 9 . Digit-by-digit representation of a positive integer number (powers of 10): Number: 9372 hundreds tens thousands units 9 3 7 2 9 thousands, 3 hundreds, 7 tens, and 2 units 103 102 101 100 9372 = 9×103 + 3×102 + 7×101 + 2×100 POSITIONAL NUMBER REPRESENTATION . Let’s consider the numbers from 0 to 999. We represent these numbers with 3 digits (each digit being a number between 0 and 9). We show a 3-digit number using the positional number representation: MATHEMATICAL REPRESENTATION EXAMPLE 3-digit d2 d1 d0 2 0 9 Third Digit Second Digit First Digit Third Digit Second Digit First Digit 2 1 . The positional number representation allows us to express the decimal value using powers of ten: 푑2 × 10 + 푑1 × 10 + 0 푑0 × 10 . Example: Decimal 3-digit representation Powers of 10: 2 1 0 Number d2d1d0 d2 10 + d1 10 + d0 10 0 000 0 102 + 0 101 + 0 100 9 009 0 102 + 0 101 + 9 100 2 1 0 11 011 0 10 + 1 10 + 1 10 2 1 0 25 025 0 10 + 2 10 + 5 10 90 090 0 102 + 9 101 + 0 100 128 128 1 102 + 2 101 + 8 100 2 1 0 255 255 2 10 + 5 10 + 5 10 Exercise: Write down the 3-digit and the powers of ten representations for the following numbers: 2 1 0 Decimal Number 3-digit representation 푑2 × 10 + 푑1 × 10 + 푑0 × 10 5 254 100 99 1 Instructor: Daniel Llamocca ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall 2016 General Case: . Positional number representation for an integer positive number with 푛 digits: dn-1dn-2 ... d1d0 Decimal Value: 푖=푛−1 푖 푛−1 푛−2 1 0 퐷 = ∑ 푑푖 × 10 = 푑푛−1 × 10 + 푑푛−2 × 10 + ⋯ + 푑1 × 10 + 푑0 × 10 푖=0 . Example: 1098324 (7 digits). 1098324 1106 0 105 9 104 8 103 3102 2 101 4 100 203476 (6 digits). 203476 2 105 0 104 3103 4 102 7 101 6 100 Maximum value: . The table presents the maximum attainable value for a given number of digits. What pattern do you find? Can you complete it for the highlighted cases (4 and 6)? Number of digits Maximum value Range 1 9 = 101-1 0 9 0 101-1 2 99 = 102-1 0 99 0 102-1 3 999 = 103-1 0 999 0 103-1 4 5 99999 = 105-1 0 99999 0 105-1 6 … n 999…999 = 10n-1 0 999…999 0 10n-1 . Maximum value for a number with ‘n’ digits: Based on the table, the maximum decimal value for a number with ‘n’ digits is given by: n-1 n-2 1 0 n D = 999...999 = 9 10 + 9 10 + ... + 9 10 + 9 10 = 10 -1 n digits With ‘n’ digits, we can represent 10n positive integer numbers from 0 to 10n-1. With 7 digits, what is the range (starting from 0) of positive numbers that we can represent? How many different numbers can we represent? BINARY NUMBER SYSTEM . We are used to the decimal number system. However, there exist other number DIGIT BIT systems: octal, hexadecimal, vigesimal, binary, etc. In particular, binary numbers are very practical as they are used by digital computers. For binary numbers, the counterpart of the decimal digit (that can take values from 0 to 9) 0 1 2 3 4 5 6 7 8 9 0 1 is the binary digit, or bit (that can take the value of 0 or 1). Bit: Unit of information that a computer uses to process and retrieve data. It can also be used as a Boolean variable (see Unit 1). Binary number: This is represented by a string of bits using the positional number representation: 푏푛−1푏푛−2 … 푏1푏0 . Converting a binary number into a decimal number: The following figure depicts two cases: 2-bit numbers and 3-bit numbers. Note that the positional representation with powers of two let us obtain the decimal value (integer positive) of the binary number. 2 Instructor: Daniel Llamocca ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall 2016 Binary number Powers of 2: Decimal MATHEMATICAL REPRESENTATION b b b 21 + b 20 1 0 1 0 Number 2-bit 1 0 b b 00 0 2 + 0 2 0 1 0 01 0 21 + 1 20 1 1 0 10 1 2 + 0 2 2 1 0 Second Bit First Bit 11 1 2 + 1 2 3 Binary number Powers of 2: Decimal 2 1 0 b2b1b0 b2 2 + b1 2 + b0 2 Number 000 0 22 + 0 21 + 0 20 0 MATHEMATICAL REPRESENTATION 001 0 22 + 0 21 + 1 20 1 3-bit 2 1 0 b b b 010 0 2 + 1 2 + 0 2 2 2 1 0 011 0 22 + 1 21 + 1 20 3 100 1 22 + 0 21 + 0 20 4 2 1 0 Third Bit Second Bit First Bit 101 1 2 + 0 2 + 1 2 5 110 1 22 + 1 21 + 0 20 6 2 1 0 111 1 2 + 1 2 + 1 2 7 General case: . Positional number representation for a binary number with ‘n’ bits: b b ... b b n-1 n-2 1 0 Most significant Least significant (leftmost) bit (rightmost) bit The binary number can be converted to a positive decimal number by using the following formula: 푖=푛−1 푖 푛−1 푛−2 1 0 퐷 = ∑ 푏푖 × 2 = 푏푛−1 × 2 + 푏푛−2 × 2 + ⋯ + 푏1 × 2 + 푏0 × 2 푖=0 . To avoid confusion, we usually write a binary number and attach a suffix ‘2’: (푏푛−1푏푛−2 … 푏1푏0)2 5 4 3 2 1 0 . Example: 6 푏푡푠: (101011)2 ≡ 퐷 = 1 × 2 + 0 × 2 + 1 × 2 + 0 × 2 + 1 × 2 + 1 × 2 = 43 3 2 1 0 4 푏푡푠: (1011)2 ≡ 퐷 = 1 × 2 + 0 × 2 + 1 × 2 + 1 × 2 = 11 . Maximum value for a given number of bits. Complete the tables for the highlighted cases (4 and 6): Number of bits Maximum value Range 1 1 1 12 2 -1 0 12 0 2 -1 2 2 2 112 2 -1 0 112 0 2 -1 3 3 3 1112 2 -1 0 1112 0 2 -1 4 5 5 5 111112 2 -1 0 111112 0 2 -1 6 … n n n 111…1112 2 -1 0 111…1112 0 2 -1 . Maximum value for ‘n’ bits: The maximum binary number is given by an n-bit string of 1’s: 111…111. Then, the maximum decimal numbers is given by: n-1 n-2 1 0 n D = 111...111 = 1 2 + 1 2 + ... + 1 2 + 1 2 = 2 -1 n bits With ‘n’ bits, we can represent 2n positive integer numbers from 0 to 2n-1. 3 Instructor: Daniel Llamocca ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall 2016 . The case n=8 bits is of particular interest, as a string of 8 bits is called a byte. For 8-bit numbers, we have 256 numbers in the range 0 to 28-1 0 to 255. b b b b b b b7 6 5 4 3 2 1b0 Most significant Least significant (leftmost) bit (rightmost) bit . The table shows some examples: 8-bit format Decimal 7 6 5 4 3 2 1 0 b b b b b b d d b7 2 + b6 2 + b5 2 + b4 2 + b3 2 + b2 2 + b1 2 + b0 2 Number 7 6 5 4 3 2 1 0 0 00000000 0 27 + 0 26 + 0 25 + 0 24 + 0 23 + 0 22 + 0 21 + 0 20 9 00001001 0 27 + 0 26 + 0 25 + 0 24 + 1 23 + 0 22 + 0 21 + 1 20 11 00001011 0 27 + 0 26 + 0 25 + 0 24 + 1 23 + 0 22 + 1 21 + 1 20 25 00011001 0 27 + 0 26 + 0 25 + 1 24 + 1 23 + 0 22 + 0 21 + 1 20 90 01011010 0 27 + 1 26 + 0 25 + 1 24 + 1 23 + 0 22 + 1 21 + 0 20 128 10000000 1 27 + 0 26 + 0 25 + 0 24 + 0 23 + 0 22 + 0 21 + 0 20 255 11111111 1 27 + 1 26 + 1 25 + 1 24 + 1 23 + 1 22 + 1 21 + 1 20 Exercise: Convert the following binary numbers (positive integers) to their decimal values: Decimal 8-bit representation 푏 × 27 + 푏 × 26 + 푏 × 25 + 푏 × 24 + 푏 × 23 + 푏 × 22 + 푏 × 21 + 푏 × 20 7 6 5 4 3 2 1 0 Number 00000001 00001001 10000101 10000111 11110011 CONVERSION OF A NUMBER IN ANY BASE TO THE DECIMAL SYSTEM . To convert a number of base 'r' (r = 2, 3,4 ,…) to decimal, we use the following formula: Number in base 'r': (푟푛−1푟푛−2 … 푟1푟0)푟 Conversion to decimal: 푖=푛−1 푖 푛−1 푛−2 1 0 퐷 = ∑ 푟푖 × 푟 = 푟푛−1 × 푟 + 푟푛−2 × 푟 + ⋯ + 푟1 × 푟 + 푟0 × 푟 푖=0 Also, the maximum decimal value for a number in base 'r' with 'n' digits is: 푛−1 푛−2 1 0 푛 퐷 = 푟푟푟 … 푟푟푟 = 푟 × 푟 + 푟푛−2 × 푟 + ⋯ + 푟 × 푟 + 푟 × 푟 = 푟 − 1 . Example: Base-8: Number of digits Maximum value Range 1 1 1 78 8 -1 0 78 0 8 -1 2 2 2 778 8 -1 0 778 0 8 -1 3 3 3 7778 8 -1 0 7778 0 8 -1 … n n n 777…7778 8 -1 0 777…7778 0 8 -1 Examples: .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    24 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us