public static long hexStringToLong(final String hexString) {
    Preconditions.checkNotNull(hexString, "Error: Unicode string can't be null");
    Preconditions.checkArgument(
        isHexString(hexString),
        String.format("Error: Hex string '%s' is not a valid hex string", hexString));

    if ((hexString.length() == 16) && (hexString.charAt(0) >= 8)) {
      // Reason: Long.parseLong(x, 16) throws NumberFormatException when
      // x is a negative value (x >= 8000.0000.0000.0000)! NH

      final String strAddr1 = hexString.substring(0, hexString.length() - 8);
      final String strAddr2 = hexString.substring(hexString.length() - 8);

      return (Long.parseLong(strAddr1, 16) << 32) + Long.parseLong(strAddr2, 16);
    }

    return Long.parseLong(hexString, 16);
  }
Converts an hex string to long.

@param hexString string to convert.
@return The hex string.
java/zylib/src/main/java/com/google/security/zynamics/zylib/general/Convert.java