in src/main/java/org/apache/commons/lang3/Conversion.java [114:147]
public static char binaryBeMsb0ToHexDigit(final boolean[] src, final int srcPos) {
// JDK 9: Objects.checkIndex(int index, int length)
if (Integer.compareUnsigned(srcPos, src.length) >= 0) {
// Throw the correct exception
if (src.length == 0) {
throw new IllegalArgumentException("Cannot convert an empty array.");
}
throw new IndexOutOfBoundsException(srcPos + " is not within array length " + src.length);
}
// Little-endian bit 0 position
final int pos = src.length - 1 - srcPos;
if (3 <= pos && src[pos - 3]) {
if (src[pos - 2]) {
if (src[pos - 1]) {
return src[pos] ? 'f' : 'e';
}
return src[pos] ? 'd' : 'c';
}
if (src[pos - 1]) {
return src[pos] ? 'b' : 'a';
}
return src[pos] ? '9' : '8';
}
if (2 <= pos && src[pos - 2]) {
if (src[pos - 1]) {
return src[pos] ? '7' : '6';
}
return src[pos] ? '5' : '4';
}
if (1 <= pos && src[pos - 1]) {
return src[pos] ? '3' : '2';
}
return src[pos] ? '1' : '0';
}