Java Byte Array to Endian bytesToLongLittleEndian(final byte[] vals, final int from)

Here you can find the source of bytesToLongLittleEndian(final byte[] vals, final int from)

Description

bytes into single long

License

Open Source License

Parameter

Parameter Description
vals raw data
from offset in array

Return

long

Declaration

public static long bytesToLongLittleEndian(final byte[] vals, final int from) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w  w  .ja  va 2 s . c om
     * <code>bytes</code> into single <code>long</code>
     * @param vals raw data
     * @param from offset in array
     * @return long
     */
    public static long bytesToLongLittleEndian(final byte[] vals, final int from) {
        final int bot = (vals[from + 3] << 24) + ((vals[from + 2] & 0xFF) << 16) + ((vals[from + 1] & 0xFF) << 8)
                + (vals[from] & 0xFF);
        final int top = (vals[from + 7] << 24) + ((vals[from + 6] & 0xFF) << 16) + ((vals[from + 5] & 0xFF) << 8)
                + (vals[from + 4] & 0xFF);
        return ((long) top << 32) + ((long) bot & 0xFFFFFFFFL);
    }
}

Related

  1. BytesToDouble_With_Little_Endian(byte[] bytes)
  2. bytesToInt(byte[] bytes, int offset, int length, boolean littleEndian)
  3. bytesToInt32(byte[] buffer, int byteOffset, boolean bigEndian)
  4. bytesToIntBigEndian(byte[] buf)
  5. bytesToIntLE(byte[] bytes, int offset, int length)
  6. bytesToNumberLittleEndian(byte[] buffer, int start, int length)
  7. bytesToTag(byte[] bytes, int off, boolean bigEndian)
  8. bytesToXBigEndian(byte[] in, int offset, int size)