Java Long Number Create toLong(byte[] value)

Here you can find the source of toLong(byte[] value)

Description

to Long

License

Open Source License

Declaration

public static long toLong(byte[] value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long toLong(byte[] value) {
        return toLong(value, 0);
    }// w  w  w  .j  a  va 2s.  co m

    /**
     * byte[] -> long
     * 
     * @param value
     * @param offset
     * @return
     */
    public static long toLong(byte[] value, int offset) {
        long result = 0L;
        result = result | (value[7] & 0xff);
        result = result | (((long) value[offset + 6] & 0xff) << 8);
        result = result | (((long) value[offset + 5] & 0xff) << 16);
        result = result | (((long) value[offset + 4] & 0xff) << 24);
        result = result | (((long) value[offset + 3] & 0xff) << 32);
        result = result | (((long) value[offset + 2] & 0xff) << 40);
        result = result | (((long) value[offset + 1] & 0xff) << 48);
        result = result | (((long) value[offset + 0] & 0xff) << 56);
        return result;
    }
}

Related

  1. toLong(byte[] si, boolean isReverseOrder)
  2. toLong(byte[] src)
  3. toLong(byte[] src, int srcPos)
  4. toLong(byte[] v)
  5. toLong(byte[] value)
  6. toLong(byte[] vint)
  7. toLong(double val)
  8. toLong(double[] in, long[] out)
  9. toLong(double[] v)