List of utility methods to do Hex to Int
int | convertHexBytesToInt(byte[] hex) convert Hex Bytes To Int String hexString = stringify_nospaces(hex);
String asciiString = convertHexToString(hexString);
return convertHexStringToInt(asciiString);
|
int | convertHexDigitAsInt(char c) convert Hex Digit As Int if (c >= '0' && c <= '9') return c - '0'; if (c >= 'A' && c <= 'F') return c - 'A' + 10; if (c >= 'a' && c <= 'f') return c - 'a' + 10; return 0; |
int | convertHexStringToInt(String hex) convert Hex String To Int return Integer.valueOf(hex, 16);
|
int | convertHexStringToInt(String hexString) convert Hex String To Int int val = 0; if ((hexString != null) && (hexString.length() > 0)) { String hexVal = hexString.trim(); int ndex = 0; if (hexVal.startsWith("0x")) ndex = 2; hexVal = hexVal.substring(ndex); val = Integer.parseInt(hexVal, 16); ... |
String | convertHexToDec(String in) convert Hex To Dec if (in == null) { return null; } else { if (in.equals("**")) return "*"; int hex = Integer.parseInt(in, 16); return String.valueOf(Integer.toString(hex)); |
int | convertHexToInt(String hex) Wandle 4-stellige Hexadezimalkodierung in Nummer um (z.B. hex = hex.toLowerCase(); char[] chex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; int[] c = { 0, 0, 0, 0 }; for (int j = 0; j < 4; j++) { for (int i = 0; i < 16; i++) { if (hex.charAt(j) == chex[i]) { c[j] = i; int no = (c[3] + (16 * c[2]) + (16 * 16 * c[1]) + (16 * 16 * 16 * c[0])); return no; |
int | hexChar2dec(char hex) hex Chardec if (hex > 47 && hex < 58) { hex -= 48; } else if (hex > 64 && hex < 71) { hex -= 55; } else if (hex > 96 && hex < 103) { hex -= 87; } else { throw new RuntimeException(hex + "is not a valid hex char."); ... |
byte | hexChar2Int(char ch) hex Char Int boolean f1 = ch >= '0' && ch <= '9'; boolean f2 = ch >= 'A' && ch <= 'F'; boolean f3 = ch >= 'a' && ch <= 'f'; if (!(f1 || f2 || f3)) { return -1; if (f1) { return (byte) (ch - '0'); ... |