CPSC170A
Fundamentals of Computer Science II

Lab 17

Binary

Binary

  1. What is the binary number 10101010 in decimal?

  2. What is the decimal number 72 in binary?

  3. What is the largest number, in binary, that can be represented with 8 bits?

  4. What is the largest number, in decimal, that can be represented with 8 bits?

  5. What is the largest number that can be represented with an int in C++. Don’t look this up, write a program to help you figure it out.

  6. How many bits are needed to store the largest number that can be represented with an int in C++?


Two’s Complement

  1. What is the 8-bit two’s complement binary number 10101010 in decimal?

  2. What is the decimal number -72 in 8-bit two’s complement binary?

  3. What is the largest number that can be represented with an 8-bit two’s complement binary? Give your answer in both binary and in decimal.

  4. What is the smallest number that can be represented with an 8-bit two’s complement binary? Give your answer in both binary and in decimal.

  5. What is the smallest number that can be represented with an int in C++. Again don’t look this up, write a program to help you figure it out.

  6. How many bits are used to store an int in C++?