I am taking a beginning C++ class, and would like to convert letters between hex representations and binary. I can manage to print out the hex numbers using:
You can easily write a mapping between the hex charachters an their binary 'nibbles':
std::string HexCharToNibble( char c ) {
switch (c) {
case '0': return "0000";
case '1': return "0001";
//... fill in the rest
case 'f': return "1111";
default: assert(false); return "bad input";
};