Android Utililty Methods Byte Array to Long Convert

List of utility methods to do Byte Array to Long Convert

Description

The list of methods to do Byte Array to Long Convert are organized into topic(s).

Method

longswap64bitFromArray(byte[] value, int offset)
Reads a signed 64 bit integer from an array coming from a device.
long v = 0;
v |= ((long) value[offset]) & 0x00000000000000FFL;
v |= (((long) value[offset + 1]) & 0x00000000000000FFL) << 8;
v |= (((long) value[offset + 2]) & 0x00000000000000FFL) << 16;
v |= (((long) value[offset + 3]) & 0x00000000000000FFL) << 24;
v |= (((long) value[offset + 4]) & 0x00000000000000FFL) << 32;
v |= (((long) value[offset + 5]) & 0x00000000000000FFL) << 40;
v |= (((long) value[offset + 6]) & 0x00000000000000FFL) << 48;
...
longtoLong(byte[] in)
to Long
long out = 0;
for (int i = in.length - 1; i > 0; i--) {
    out |= in[i] & 0xff;
    out <<= 8;
out |= in[0] & 0xff;
return out;
longparseLong(byte[] b, int start, int end, int radix)
Convert the bytes within the specified range of the given byte array into a signed long in the given radix .
if (b == null)
    throw new NumberFormatException("null");
long result = 0;
boolean negative = false;
int i = start;
long limit;
long multmin;
int digit;
...
longparseLong(byte[] b, int start, int end)
Convert the bytes within the specified range of the given byte array into a signed long .
return parseLong(b, start, end, 10);
longbytes2long(byte[] b)
byteslong
int mask = 0xff;
int temp = 0;
int res = 0;
for (int i = 0; i < 8; i++) {
    res <<= 8;
    temp = b[i] & mask;
    res |= temp;
return res;
longbyteArrayToLong(byte[] arr)
byte Array To Long
return ByteBuffer.wrap(arr).getLong();
longbyteArrayToLong(byte[] b)
byte Array To Long
return (long) (b[0] << 56) + ((long) (b[1] & 0xFF) << 48)
        + ((long) (b[2] & 0xFF) << 40)
        + ((long) (b[3] & 0xFF) << 32)
        + ((long) (b[4] & 0xFF) << 24)
        + ((long) (b[5] & 0xFF) << 16)
        + ((long) (b[6] & 0xFF) << 8) + ((long) b[7] & 0xFF);
longbyteArrayToLong(byte[] bArray)
byte Array To Long
long a = 0;
for (int i = 0; i < bArray.length; i++) {
    a += (long) ((bArray[i] & 0XFF) << (8 * i));
return a;
longbytesBE2long(byte[] b, int off)
bytes B Elong
return ((b[off] & 0xffL) << 56) | ((b[off + 1] & 0xffL) << 48)
        | ((b[off + 2] & 0xffL) << 40)
        | ((b[off + 3] & 0xffL) << 32)
        | ((b[off + 4] & 0xffL) << 24)
        | ((b[off + 5] & 0xffL) << 16)
        | ((b[off + 6] & 0xffL) << 8) | (b[off + 7] & 0xffL);
long[]bytesBE2longs(byte[] b)
bytes B Elongs
if (b == null)
    return null;
if ((b.length & 0x7) != 0)
    throw new IllegalArgumentException("byte[" + b.length + "]");
long[] val = new long[b.length >> 3];
for (int i = 0; i < val.length; i++)
    val[i] = bytesBE2long(b, i << 3);
return val;
...