Department of Computer Science         Homework: Java Primitive Data Types and Base Conversion
  1. Use repeated division/multiplication by 8 and a binary 3-digit lookup to convert the following numbers by hand.
    1. 88



    2. 132




    3. 132.456




    4. 103



    5. 10.1





  2. Now convert the binary numbers found in problem #1 to hexadecimal utilizing a 4-digit lookup.















  3. Convert the following binary numbers to decimal, hex, and octal. Then convert each octal and hex number back to decimal.
    1. 1010.0001100110011
      (23 + 21) . (2-4 + 2-5 + 2-8 + 2-9 + 2-12 + 2-13) = 10.099975585938
      1 010.000 110 011 001 1 = 12.063148
      1010.0001 1001 1001 1 = A.199816
      12.063148 = (81 + 2× 80) . (6× 8-2 + 3× 8-3 + 8-4 + 4× 8-5) = 10.099975585938
      A.199816 = (10× 160) . (16-1 + 9× 16-2 + 9× 16-3 + 8× 16-4) = 10.099975585938
    2. 1000011







    3. 10110000.001101001011







    4. 1001001




  4. Write the following numbers as Java bytes then convert the Java bytes to hexadecimal.
    1. 123



    2. -123



    3. 8



    4. -8


  5. Write the following as Java integers, convert the Java word to hexadecimal.
    1. 129


    2. -129


    3. 12,500



    4. -12,500


  6. Write the following numbers as Java floats, convert the Java word to hexadecimal.
    1. 176.2058 = 0100 0011 0011 0000 0011 0100 1010 1111 = 433034AF







    2. -132.456




    3. -10.1




  7. Convert the following Java words representing floats to their decimal values (spaces added to enhance readability, sign bit is at the left).
    1. 1100 0010 0000 0011 1000 0001 1001 0100
      C203819416

Key


Back by J. A. Tompkins tompkinsj@uncw.edu