Hexadecimal is commonly used because of the fact that it four binary bits happen to be one hexadecimal character (since its base 16 and four bits give you values 0-15).
Therefore, to go from binary to hex (random binary sequence):
1001 1101 1111 0010
---9----D----F----2 (put dashes for spacing)
Now, if you want to do this programmatically, the hex interpretation is merely a human readable form. All numbers are stored as binary internally, so conversion to hex really doesn't provide anything significant besides readability.
int value = 11;
CString hex_val;
hex_val.Format("%X",value);