Integer conversion


For the following, perform the listed series of conversions.

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 5 values listed in a column.

List generator

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


Use divide by 2 (divisor) method to convert to binary.

77
DividendQuotientRemainder
7738 1
3819 0
19  9 1
9  4 1
4  2 0
2  1 0
1  0 1
1001101

Subtracting powers of 2
  2^7   2^6   2^5   2^4   2^3   2^2  2^1  2^0
  128    64    32    16     8     4    2    1

 2^15  2^14  2^13  2^12  2^11  2^10  2^9  2^8
32768 16384  8192  4096  2048  1024  512  256
77
77 - ( 64 * 1 ) = 13
13 - ( 32 * 0 ) = 13
13 - ( 16 * 0 ) = 13
13 - (  8 * 1 ) =  5
 5 - (  4 * 1 ) =  1
 1 - (  2 * 0 ) =  1
 1 - (  1 * 1 ) =  0
     1001101

Use multiply by 2 to convert binary to decimal.

BitcalculationSum
11+0 1
00+1*2 2
00+2*2 4
11+4*2 9
11+9*2 19
00+19*2 38
11+38*2 77

Summing powers
    1 *  64   64
    0 *  32    0   
    0 *  16    0   
    1 *   8    8   72
    1 *   4    4
    0 *   2    0 
    1 *   1    1    5    77

Hex
   0    1    2    3    4    5    6    7 
0000 0001 0010 0011 0100 0101 0110 0111 

   8    9    A    B    C    D    E    F
1000 1001 1010 1011 1100 1101 1110 1111

Hex 
    0 0 0 0  0 0 0 0  0 1 0 0  1 1 0 1 
          0        0        4        D  Hexadecimal

Octal 
    0  0 0 0  0 0 0  0 0 1  0 0 1  1 0 1 
    0      0      0      1      1      5  Octal


Two's complement :

0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 : value left padded to 16 bit. 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 0 : 1's complement. + 1 : add 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 : 2's complement. Convert back to unsigned using shift(multiply) and add. 1 1 1 1 2+1 3 1 6+1 7 1 14+1 15 1 30+1 31 1 62+1 63 1 126+1 127 1 254+1 255 1 510+1 511 0 1022+0 1022 1 2044+1 2045 1 4090+1 4091 0 8182+0 8182 0 16364+0 16364 1 32728+1 32729 1 65458+1 65459

For each number, :

  1. Convert from decimal to binary using both methods. Show math.
  2. Convert back to decimal to check. Use both methods. Show math.
  3. Convert binary to hexadecimal. (base 16)
  4. Convert binary to octal. (base 8)
  5. Apply 2's complement on the binary to give negative (Use 16 bit)
  6. Give the hexadecimal representation of the 2's complement value.
  7. Give the unsigned value of the 2's complement value.
Note : 2^16 = 65536, If you subtract the negative value from that, you get the unsigned equivalent of the two's complement. 65536 - 77 = 65459