CS 111: Introduction to Computer Science

Binary arithmetic

  1. For each of the following positive binary integers, what are the decimal (base ten) and hexadecimal (base sixteen) equivalents?

    • 11010
    • 11011001
    • 1
  2. Add 11110 to 1101. Show your work (in particular, show where you get carries, and where you don't). You can check your work by translating the numbers into decimal, but I want to see you do the usual gradeschool addition algorithm in base 2 instead of base ten.

  3. The number 1.398 is equal to 1 + 3/10 + 9/100 + 8/1000. If we move to binary, and use a "binary point" instead of a decimal point, what will the following numbers equal? That is, what are the base ten equivalents of the following binary numbers?

    • 10.11
    • 0.101

    When you multiply a decimal number by 10, you shift the decimal point to the right one place. How can you shift a binary point to the right?

  4. Rewrite the following base-ten numbers as 16-bit two's complement integers: -1, 127, -127, and 1232.

  5. What does the bit pattern 01100101 represent if you interpret it as an 8-bit two's complement integer? What if you interpret it as a character using ASCII?