C int type is (typically) represented using 32 bits (32 1's and 0's).
Since each hex digit is equivalent to 4 bits, an int can also be represented with only 8 hex 'digits' ( 4 * 8 = 32).
Converting hex to binary is easy:
-
Replace each hex digit by the corresponding 4 bits
In C programs, hex integers are indicated by prefix 0x or 0X
Example:
Write 0x5CA in binary (should be 3 hex digits * 4 bits/hex digit = 12 bits)
Convert hex 0x5CA to binary (1) Convert each hex digit to the corresponding 4 binary bits: Hex: 0x 5 C A Binary: 0101 1101 1010 Answer: 010111011010