Java Long Number Create convertLongFromBytes(byte[] bytes)

Here you can find the source of convertLongFromBytes(byte[] bytes)

Description

convert Long From Bytes

License

Open Source License

Declaration

public static long convertLongFromBytes(byte[] bytes) 

Method Source Code

//package com.java2s;

public class Main {
    public static long convertLongFromBytes(byte[] bytes) {
        return convertLongFromBytes(bytes, 0);
    }/*w w  w .  j a v a2 s  .co m*/

    public static long convertLongFromBytes(byte[] bytes, int offset) {
        // Convert it to an long
        return ((((long) bytes[offset + 7]) & 0xFF)
                + ((((long) bytes[offset + 6]) & 0xFF) << 8)
                + ((((long) bytes[offset + 5]) & 0xFF) << 16)
                + ((((long) bytes[offset + 4]) & 0xFF) << 24)
                + ((((long) bytes[offset + 3]) & 0xFF) << 32)
                + ((((long) bytes[offset + 2]) & 0xFF) << 40)
                + ((((long) bytes[offset + 1]) & 0xFF) << 48) + ((((long) bytes[offset + 0]) & 0xFF) << 56));
    }
}

Related

  1. convertLong2FourBytes(long data)
  2. convertLongAddressToBuf(long ipAddress)
  3. convertLongArray(long[] arr)
  4. convertLongArrayFromHex(char[] hex)
  5. convertLongArrayToDoubleArray(long[] values)
  6. convertLongitudeFromMercator( double mercatorLongitude)
  7. convertLongPriceToString(long price)
  8. convertLongtoMultiByte(long val)
  9. fromLong(byte[] buffer, int pos, long l)