Homework: Java Primitive Data Types and Base Conversion
- Use repeated division/multiplication by 8 and a binary 3-digit lookup to convert the following numbers by hand.
- 88
- 132
- 132.456
- 103
- 10.1
- Now convert the binary numbers found in problem #1 to hexadecimal utilizing a
4-digit lookup.
- Convert the following binary numbers to decimal, hex, and octal. Then convert each octal and hex number back to decimal.
- 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
- 1000011
- 10110000.001101001011
- 1001001
- Write the following numbers as Java bytes then convert the Java bytes to hexadecimal.
- 123
- -123
- 8
- -8
- Write the following as Java integers, convert the Java word to hexadecimal.
- 129
- -129
- 12,500
- -12,500
- Write the following numbers as Java floats, convert the Java word to hexadecimal.
- 176.2058 = 0100 0011 0011 0000 0011 0100 1010 1111 = 433034AF
- -132.456
- -10.1
- Convert the following Java words representing floats to their decimal values (spaces added to enhance readability, sign bit is at the left).
- 1100 0010 0000 0011 1000 0001 1001 0100
C203819416
Key
by J. A. Tompkins tompkinsj@uncw.edu