List of utility methods to do Byte Array to Long Convert
long | getLong(byte[] buf, int pos, boolean bigEndian) Convert byte sequence into java long. if (bigEndian) { return (((long) buf[pos + 7]) & 0xFF) | ((((long) buf[pos + 6]) & 0xFF) << 8) | ((((long) buf[pos + 5]) & 0xFF) << 16) | ((((long) buf[pos + 4]) & 0xFF) << 24) | ((((long) buf[pos + 3]) & 0xFF) << 32) | ((((long) buf[pos + 2]) & 0xFF) << 40) | ((((long) buf[pos + 1]) & 0xFF) << 48) ... |
long | getLong(byte[] bytes) get Long return (0xffL & (long) bytes[0]) | (0xff00L & ((long) bytes[1] << 8)) | (0xff0000L & ((long) bytes[2] << 16)) | (0xff000000L & ((long) bytes[3] << 24)) | (0xff00000000L & ((long) bytes[4] << 32)) | (0xff0000000000L & ((long) bytes[5] << 40)) | (0xff000000000000L & ((long) bytes[6] << 48)) | (0xff00000000000000L & ((long) bytes[7] << 56)); ... |
long | getLong4(byte[] b, int offset) get Long long ret = (b[offset] & 0xffL) << 24; ret += ((b[offset + 1] & 0xffL) << 16); ret += ((b[offset + 2] & 0xffL) << 8); ret += (b[offset + 3] & 0xffL); return ret; |
long | getLong5(byte[] b, int offset) get Long long ret = (b[offset] & 0xffL) << 32; ret += ((b[offset + 1] & 0xffL)) << 24; ret += ((b[offset + 2] & 0xffL) << 16); ret += ((b[offset + 3] & 0xffL) << 8); ret += (b[offset + 4] & 0xffL); return ret; |
long | getLongFromByteArray(final byte[] bytes) Converts a byte array to a long. return ByteBuffer.wrap(bytes).getLong();
|
long | toLong(byte[] b, int pos) to Long return toLong(b, pos, 8);
|
long | toLong(byte[] b, int pos, int width) to Long long ret = 0; for (int i = 0; i < width; i++) { ret |= (b[i + pos] & 0xFFl) << (8 * i); return ret; |
long | toLong(byte[] src) to Long return toLong(src, 0);
|
long | toLong(byte[] src, int srcPos) to Long long qword = 0; for (int i = 0; i < 8; i++) { qword = (qword << 8) + (src[i + srcPos] & 0xFF); return qword; |
long | makeLong(byte b7, byte b6, byte b5, byte b4, byte b3, byte b2, byte b1, byte b0) make Long return ((((long) b7 & 0xff) << 56) | (((long) b6 & 0xff) << 48) | (((long) b5 & 0xff) << 40) | (((long) b4 & 0xff) << 32) | (((long) b3 & 0xff) << 24) | (((long) b2 & 0xff) << 16) | (((long) b1 & 0xff) << 8) | (((long) b0 & 0xff) << 0)); |