Java Long Number Create toLong(byte[] buf, int pos)

Here you can find the source of toLong(byte[] buf, int pos)

Description

to Long

License

Apache License

Declaration

public static long toLong(byte[] buf, int pos) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static long toLong(byte[] buf, int pos) {
        return ((long) toUnsignedByte(buf, pos + 0)) << 56 + ((long) toUnsignedByte(buf, pos + 1)) << 48
                + ((long) toUnsignedByte(buf, pos + 2)) << 40 + ((long) toUnsignedByte(buf, pos + 3)) << 32
                        + ((long) toUnsignedByte(buf, pos + 4)) << 24 + ((long) toUnsignedByte(buf, pos + 5)) << 16
                                + ((long) toUnsignedByte(buf, pos + 6)) << 8
                                        + ((long) toUnsignedByte(buf, pos + 7));
    }//from w  ww. ja  va 2 s .c o m

    public static int toUnsignedByte(byte[] buf, int pos) {
        int b = buf[pos];
        if (b < 0) {
            b = 256 + b;
        }
        return b;
    }
}

Related

  1. toLong(byte[] b)
  2. toLong(byte[] b, int off, boolean bigEndian)
  3. toLong(byte[] buf)
  4. toLong(byte[] buf)
  5. toLong(byte[] buf, int off)
  6. toLong(byte[] byteArray)
  7. toLong(byte[] bytes)
  8. toLong(byte[] bytes)
  9. toLong(byte[] bytes)