13 if (s[0] ==
'0' and std::tolower(s[1]) ==
'x' and s.size()>2) {
14 s.assign(std::begin(s)+2, std::end(s));
16 std::string alpha{
"abcdef"};
21 if (std::isdigit(c)) {
22 num = int(c) - int(
'0');
23 }
else if (alpha.find(c) != std::string::npos){
24 num = int(c) - int(
'a') + 10;
26 throw std::out_of_range(
"not hex character");
30 for (
int j = 3; j != -1; --j) {
31 result += (mask & num) ?
'1' :
'0';