Android Byte Array to Long Convert bytes2ulong(byte[] bytes, int from, int to)

Here you can find the source of bytes2ulong(byte[] bytes, int from, int to)

Description

bytesulong

Declaration

public static long bytes2ulong(byte[] bytes, int from, int to) 

Method Source Code

//package com.java2s;

public class Main {
    public static long bytes2ulong(byte[] bytes, int from, int to) {
        long result = 0;

        int len = to - from;

        for (int i = from; i < to; i++) {
            int shiftValue = (to - i - 1) * 8;

            result += (bytes[i] << shiftValue)
                    & (0xFFFFFFFF >>> ((len - 1) * 8 - shiftValue));
        }//from  w ww  .  ja  v a  2  s. co m

        return result;
    }
}

Related

  1. bytesLE2long(byte[] b, int off)
  2. bytesLE2longs(byte[] b)
  3. bytesToLong(byte[] bytes)
  4. bytesToLong(byte[] bytes)
  5. bytesToLong(byte[] bytes, int start)
  6. getLong(byte[] bb, int index)
  7. getLong(byte[] bb, int index)
  8. getLong(byte[] buf, boolean bigEndian)
  9. getLong(byte[] buf, int pos, boolean bigEndian)