List of utility methods to do Byte Array to Long
long | arr2long(byte[] b) arrlong int i = 0; int len = 4; int cnt = 0; byte[] tmp = new byte[len]; for (i = 0; i < len; i++) { tmp[cnt] = b[i]; cnt++; long accum = 0; i = 0; for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { accum |= ((long) (tmp[i] & 0xff)) << shiftBy; i++; return accum; |
long | atol(byte[] s) atol long result = 0; boolean negative = false; int i = 0, len = s.length; long limit = -Long.MAX_VALUE; long multmin; int digit; if (len > 0) { byte firstChar = s[0]; ... |
long | atol(byte[] s, int offset) atol StringBuilder sb = new StringBuilder(); char c; while ((c = (char) (s[offset++] & 0xFF)) != 0 && Character.isDigit(c)) { sb.append(c); if (sb.length() == 0) { return 0L; return Long.parseLong(sb.toString()); |
long | bufferToLong(byte[] ioBuffer) buffer To Long return ((ioBuffer[0] & 255L) << 56) + ((ioBuffer[1] & 255L) << 48) + ((ioBuffer[2] & 255L) << 40)
+ ((ioBuffer[3] & 255L) << 32) + ((ioBuffer[4] & 255L) << 24) + ((ioBuffer[5] & 255L) << 16)
+ ((ioBuffer[6] & 255L) << 8) + (ioBuffer[7] & 255L);
|
long | byte2long(byte[] b) bytelong return bytes2long(b, 0); |
long | byte2long(byte[] b) Converts byte representation to long. return ((long) b[0] & 0xff) | (((long) b[1] & 0xff) << 8) | (((long) b[2] & 0xff) << 16) | (((long) b[3] & 0xff) << 24); |
long | byte2Long(byte[] bytes, int offset) byte Long long val = 0; for (int i = 0; i < 8; i++) { byte b = bytes[i + offset]; long orBin = b & 0x7f; if (b < 0) { orBin = orBin | 0x80; val = (val << 8) | orBin; ... |
long | byte2Long(byte[] bytes, int offset) byte Long checkLength(bytes, 8, offset); long v0 = bytes[offset + 7] & 0xff; long v1 = (long) (bytes[offset + 6] & 0xff) << 8 * 1; long v2 = (long) (bytes[offset + 5] & 0xff) << 8 * 2; long v3 = (long) (bytes[offset + 4] & 0xff) << 8 * 3; long v4 = (long) (bytes[offset + 3] & 0xff) << 8 * 4; long v5 = (long) (bytes[offset + 2] & 0xff) << 8 * 5; long v6 = (long) (bytes[offset + 1] & 0xff) << 8 * 6; ... |
long | byte2long(byte[] data) bytelong if (data != null && data.length == 8) { return (((data[7] & 0xffL) << 56) | ((data[6] & 0xffL) << 48) | ((data[5] & 0xffL) << 40) | ((data[4] & 0xffL) << 32) | ((data[3] & 0xffL) << 24) | ((data[2] & 0xffL) << 16) | ((data[1] & 0xffL) << 8) | (data[0] & 0xffL)); return 0; |
long | byte2long(byte[] value, int count) bytelong long result = (((long) (value[0 + count]) & 0xFF) << 56) | (((long) (value[1 + count]) & 0xFF) << 48) | (((long) (value[2 + count]) & 0xFF) << 40) | (((long) (value[3 + count]) & 0xFF) << 32) | (((long) (value[4 + count]) & 0xFF) << 24) | (((long) (value[5 + count]) & 0xFF) << 16) | (((long) (value[6 + count]) & 0xFF) << 8) | ((long) (value[7 + count]) & 0xFF); return result; |