/** * Parses a 1 to 32 character lower-hex string with no prefix into an unsigned long, tossing any * bits higher than 64. */ public static long convertToLong(String lowerHex) { int length = lowerHex.length(); if (length < 1 || length > 32) throw isntLowerHexLong(lowerHex); // trim off any high bits int beginIndex = length > 16 ? length - 16 : 0; return convertToLong(lowerHex, beginIndex); }
/** * Parses a 16 character lower-hex string with no prefix into an unsigned long, starting at the * specified index. */ public static long convertToLong(String lowerHex, int index) { int endIndex = Math.min(index + 16, lowerHex.length()); long result = lenientConvertToLong(lowerHex, index, endIndex); if (result == 0) throw isntLowerHexLong(lowerHex); return result; }