List of utility methods to do Char to Nibble
int | charToNibble(char c) char To Nibble if ('0' <= c && c <= '9') return c - 48; if ('a' <= c && c <= 'f') return (c - 97) + 10; if ('A' <= c && c <= 'F') return (c - 65) + 10; else throw new IllegalArgumentException( ... |
int | charToNibble(char c) convert a single char to corresponding nibble using a precalculated array. if (c > 'f') { throw new IllegalArgumentException("Invalid hex character: " + c); int nibble = correspondingNibble[c]; if (nibble < 0) { throw new IllegalArgumentException("Invalid hex character: " + c); return nibble; ... |
int | charToNibble(char c) char To Nibble if (c >= '0' && c <= '9') { return c - '0'; } else if (c >= 'a' && c <= 'f') { return 0xa + (c - 'a'); } else if (c >= 'A' && c <= 'F') { return 0xA + (c - 'A'); } else { throw new RuntimeException("Not a hex character: '" + c + "'"); ... |
int | charToNibble(char c) char To Nibble if (c > 'f') { throw new IllegalArgumentException("Invalid hex character: " + c); int nibble = correspondingNibble[c]; if (nibble < 0) { throw new IllegalArgumentException("Invalid hex character: " + c); return nibble; ... |