List of utility methods to do Hex Calculate
String | toHexString(int val) Quick conversion to hex string. return toHexString(val, 4); |
String | toHexString(int val, int minLength) to Hex String StringBuilder sb = new StringBuilder(); while (val != 0) { switch (val & 0xf) { case 0x0: sb.append('0'); break; case 0x1: sb.append('1'); ... |
String | toHexString(int value, int len) Returns Hexadecimal String of specified number of digits padding with zeroes if necessary String retval = ""; for (int i = (len - 1) * 4; i >= 0; i -= 4) { int j = value >> i & 0xF; if (j > 9) { j += LOWERCASE_ASCII_MIN - 10; } else { j += NUMBER_ASCII_MIN; retval += (char) j; return retval; |
String | ToHexString(int value, int length) Format an integer to its hex representaion, with (at least) the given number of digits, left padded with '0' String answer = Integer.toHexString(value).toUpperCase(); int currentLength = answer.length(); if (currentLength < length) { answer = Zeroes.substring(0, length - currentLength) + answer; return answer; |
String | toHexString(int value, int minLength) to Hex String StringBuilder sb = new StringBuilder(Integer.toHexString(value).toUpperCase()); while (sb.length() < minLength) { sb.insert(0, '0'); return sb.toString(); |
String | toHexString(int value, int numDigits) Returns a base-10 integer as a hexadecimal number in String. StringBuilder result = new StringBuilder(); for (int i = (numDigits - 1); i >= 0; i--) { String digit = toHexDigit(value, i); result.append(digit); return result.toString().toUpperCase(); |
String | toHexString(int[] data) to Hex String if (data == null) return "null"; StringBuilder stringBuilder = new StringBuilder(data.length * 5); stringBuilder.append('['); for (int i = 0; i < data.length; i++) { stringBuilder.append(String.format("0x%02X", data[i])); if (i + 1 < data.length) stringBuilder.append(", "); ... |
String | toHexString(int[] ia) Get the hex string for the bytes. return toHexString(ia, 0, ia.length, 0);
|
String | toHexString(int[] x, int bitsPerDigit) to Hex String final int digitsPerLong = (59 / bitsPerDigit) + 1; final StringBuilder b = new StringBuilder(); for (int i = 0; i < x.length;) { long a = 0; int j = 0; for (; i < x.length && j < digitsPerLong; j++) { a |= ((long) x[i] << (bitsPerDigit * j)); i++; ... |
String | toHexString(Integer num) to Hex String String hex = Integer.toHexString(num.intValue()); switch (hex.length()) { case 0: hex = "00000000"; break; case 1: hex = "0000000" + hex; break; ... |