Assignment 1 - Integer conversion

Due in class by start of class :
Frideay 30 January 2015
65 points

For the following assignment, you will perform a series of conversions. On a seperate sheet of paper and hand written, show your work and the answer for each following problem.

For the sanity of your TA, limit your solutions to 1 to 2 number conversions on any page side of paper. Be neat. You may use both sides of the paper. Circle and number (1a., 1b, etc.) the answer. You must do all numbers.

Integers. ( points - 1 point per step per number)

Click on the "List Generator" link below to access a web page that will generate the list of numbers to convert. To get the list for you, enter the digits of your z-id. Don't enter the 'z'.

This will display a page with 10 values, 5 integer values for Part 1 and 5 binary values for Part 2. List generator

Part 1.

The numbers are in decimal base and are to be stored in a 2 byte (16 bit) signed storage. Perform the following actions :

For each number, write down the number to be converted.

  1. (2) Convert from decimal to binary using divide by 2 method. Show math.
      Ex.
         divide by 2
         123
          61 1          
          30 1
          15 0
           7 1
           3 1
           1 1
           0 1  1111011
       
  2. (2) Convert back to decimal to check. Use shift and add method. Show math.
       
          shift and add
    
             1111011
    
              1  1
              1  2+1 = 3
              1  6+1 = 7
              1  14+1 = 15
              0  30+0 = 30
              1  60+1 = 61
              1  122+1 = 123
           
  3. (1) Convert binary to hexadecimal. (base 16)
  4. (1) Convert binary to octal. (base 8)
  5. (1) Apply 2's complement on the binary to give negative (remember 16 bit)
          0000 0000 0111 1011
         
          1111 1111 1000 0100
          +                 1
          -------------------
          1111 1111 1000 0101  ( -123 signed 16-bit integer)
          
  6. (1) Give the hexadecimal representaion of the number generated in step E.
  7. (2) Use binary to decimal math to give the unsigned decimal value of the two's complement number generated in E.
Part 2.

For each number, write down the number to be converted.

  1. (3) Convert the binary back to signed decimal. If most signficant bit is a 1, number is negative. Use 2's complement before converting back.
Make sure you include your z-id with your name, so the TA can check that you have the right numbers.