Problems (Practice)

  1. (2.1) Convert:

    1. 0x39A7F8 to binary 0011 1001 1010 0111 1111 1000
    2. Binary 1100100101111011 (16 bits) to hexadecimal 0xC97B
    3. 0xD5E4C to binary 1101 0101 1110 0100 1100
    4. Binary 1001101110011110110101 (22 bits) 0x26E7B5
  2. (2.2) Fill in the blank entries in the following table, giving the decimal and hexadecimal representations of different powers of 2:

    n 2n (Decimal) 2n (Hexadecimal)
    9 512 0x200
    19 524288 0x80000
    14  16384 0x4000 
    16  65536  0x10000
    17 131072  0x20000 
    5  32 0x20 
    7  128  0x80
  3. (2.3) A single byte can be represented by two hexadecimal digits. Fill in the missing entries in the following table, giving the decimal, binary, and hexadecimal values of different byte patterns.

    Decimal Binary Hexadecimal
    0 0000 0000 0x00
    167 1010 0111  0xa7 
    62 0011 1110  0x3e 
    188 1011 1100  0xbc 
    55  0011 0111 0x37 
    136  1000 1000 0x88 
    243  1111 0011 0xf3 
    82  0101 0010  0x52
    172  1010 1100  0xAC
    231  1110 0111  0xE7
  4. (2.4) Without converting the number to decimal of binary, try to solve the following arithmetic problems, giving the answers in hexadecimal.

    1.      0x503c
         +    0x8
         --------
           0x5044
      	    
    2.      0x503c
         -   0x40
         --------
           0x4ffc
      	    
    3.      0x503c
         +     64    (64 = 0x??)
         --------
           0x507c
      	      
      	    
    4.      0x50ea
         + 0x503c
         --------
           0x00ae
      	      
      	    
  5. Give the missing decimal or binary representations of the following signed byte integers (type is char). Values are represented using two's complement. So the left most bit is the 'sign' bit.

    The first two are provided as examples:

    decimal binary
    7 0000 0111
    -7 1111 1001
    21 0001 0101
    -21 11101011 
    42 0010 1010
    -42 1101 0110