Binary Numbers

Binary Numbers

Bit patterns • Bits can be used to represent patterns • Specifically, any system or set of symbols can be translated into bit patterns – patterns of ones and zeros Binary Numbers – 10100001101 • Example: characters from any language alphabet • Require enough bits so that all symbols have a unique bit pattern to represent them – How many bits are needed to represent the English alphabet? • Require set of symbols is finite How many bits? Decimal (base 10) representation • A bit pattern consisting of a single bit can represent at • We commonly represent numbers in decimal (base 10) most two symbols • Numbers are represented using patterns of the digits – possible patterns are 0 and 1 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } • A bit pattern consisting of two bits can represent at most four symbols • Position of each digit represents a power of ten – possible patterns are 00, 01, 10 and 11 • Example: Consider the decimal representation 2307 • In general, a bit pattern consisting of n bits can represent n at most 2 symbols 2307 • How many bits are needed to represent the English ↑↑↑↑ alphabet? position: 3 2 1 0 – we can represent 26 symbols using 5 bits (25=32) – 4 bits is not enough (24=16) 2307 = 2×103 + 3×102 + 0×101 + 7×100 Base n representation Binary (base 2) representation • A base n system contains n distinct symbols, the digits 0 • The binary representation contains two symbols: { 0, 1 } through n -1 • Position of each symbol represents a power of two • Numeric values greater than n -1 are represented by a • What is the value of the binary representation 111? pattern of the n symbols • The value of any symbol in the string is found by 111 p multiplying that symbol by n , where p is the distance ↑↑↑ from the rightmost symbol in the pattern position: 2 1 0 • Computers represent information using bit patterns, or binary (base 2) representation 2 1 0 • Numbers represented in base 2 are usually called binary 111 = 1×2 + 1×2 + 1×2 numbers = 1×4+ 1×2+ 1×1 = 4 + 2 + 1 = 7 1 Binary representation Binary addition • What is the value of the binary representation 1010? 0 1 0 1 + 0 + 0 + 1 + 1 ------- ------- ------- ------- 1010 0 1 1 10 ↑↑↑↑ position: 3 2 1 0 • Represent sum of binary numbers as a binary number 1010 = 1×23 + 0×22 + 1×21 + 0×20 decimal addition binary addition = 1×8 + 0×4+ 1×2+ 0×1 1+1 = 2 1+1 = 10 = 8 + 0 + 2 + 0 = 10 1+1+1 = 3 1+1+1 = 10+1 = 11 Adding binary numbers Converting decimal to binary →→conversion →→ 1 1 ← carry 1 1 ← carry Decimal Binary 101 101 111 0 + 10 + 11 + 110 0 = 0×2 = 0 --------- ----------- ----------- 1 = 1×20 = 1 111 1000 1101 2 = 1×21 + 0×20 = 10 3 = 1×21 + 1×20 = 11 2 1 0 1 1 1 ← carry 4 = 1×2 + 0×2 + 0×2 = 100 10101010111 5 = 1×22 + 0×21 + 1×20 = 101 + 110000110 6 = 1×22 + 1×21 + 0×20 = 110 ------------------------ 7 = 1×22 + 1×21 + 1×20 = 111 11011011101 8 = 1×23 + 0×22 + 0×21 + 0×20 = 1000 Converting decimal to binary Converting decimal to binary 0 remainder 1 0 remainder 1 2 1 • Repeated division by 2 1 • Repeated division by two until the quotient two until the quotient 1 remainder 0 is zero 1 remainder 1 is zero 2 2 2 3 • What is the binary • What is the binary 2 remainder 1 representation of 30? 3 remainder 1 representation of 47? 2 5 2 7 5 remainder 1 7 remainder 1 2 11 2 15 11 remainder 1 15 remainder 0 2 23 2 30 23 remainder 1 2 47 11110 111001 2 Problems Solutions • Convert 1011000 to decimal representation • Convert 1011000 to decimal representation 1011000 = 1×26 + 0×25 + 1×24 + 1×23 + 0×22 + 0×21 + 0×20 = 64 + 16 + 8 = 88 • Add the binary numbers 1011001 and 10101 and • Add the binary numbers 1011001 1011001 express their sum in binary representation and 10101 and express their sum + 10101 in binary representation ---------------- 1101110 • Convert 77 to binary representation • Convert 77 to binary representation: 1001101 Ternary (base 3) representation • Numbers are represented using the symbols { 0, 1, 2 } • Convert the ternary representation 1021 to decimal 1021 = 1×33 + 0×32 + 2×31 + 1×30 = 27 + 0 + 6 + 1 = 34 • Convert the ternary representation 2001 to decimal 2001 = 2×33 + 0×32 + 0×31 + 1×30 = 54 + 0 + 0 + 1 = 55 • Add the ternary numbers 1021 and 2001 and express their sum in ternary representation • Convert 77 to ternary representation 3.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 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