Lab 7: Information representation and binary numbers

In this lab you will practice with information representation and binary numbers. Feel free to work in pairs.

Exercise 1: Some Questions

Answer the following questions:

Exercise 2: Binary Number Addition

Add the binary numbers given below:

       1010101010            1010111011
     +  101011111          + 1101110110
    -------------         -------------

Exercise 3: Binary Number Subtraction

Do the subtractions given below:

       1010101010            1010101010
     -  101011111          -  110111011
    -------------         -------------

Exercise 4: Converting from Decimal to Binary

Convert the following numbers from decimal to binary:

   15, 70, and 111.

Exercise 5: Converting from Binary to Decimal

Convert the following numbers from binary to decimal:

   1001, 10011, and 110110.

Exercise 6: Evaluating Boolean Expressions

Suppose we have a fragment of Java code as follows:

  boolean a = true;
  boolean b = false;
  boolean c = true;
  boolean b = a || (b && c);
  boolean d = a && (b || c) || (!a);

What is the resulting value of b and d if we execute these lines in order? Hint: the order of operator precedence is !, &&, and || in that order ! being the highest. We also evaluate from left to right.