Java Long Number Create toLong(byte[] b)

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

Description

to Long

License

Open Source License

Declaration

public static long toLong(byte[] b) 

Method Source Code

//package com.java2s;
/**/*from  ww  w. ja  va  2s. c om*/
 * @(#)ByteUtils.java, 2013-2-24.
 * 
 * Copyright 2013 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {

    public static long toLong(byte[] b) {
        return ((((long) b[7]) & 0xFF) | ((((long) b[6]) & 0xFF) << 8) | ((((long) b[5]) & 0xFF) << 16)
                | ((((long) b[4]) & 0xFF) << 24) | ((((long) b[3]) & 0xFF) << 32) | ((((long) b[2]) & 0xFF) << 40)
                | ((((long) b[1]) & 0xFF) << 48) | ((((long) b[0]) & 0xFF) << 56));
    }

    public static long toLong(byte[] b, int offset) {
        return ((((long) b[offset + 7]) & 0xFF) | ((((long) b[offset + 6]) & 0xFF) << 8)
                | ((((long) b[offset + 5]) & 0xFF) << 16) | ((((long) b[offset + 4]) & 0xFF) << 24)
                | ((((long) b[offset + 3]) & 0xFF) << 32) | ((((long) b[offset + 2]) & 0xFF) << 40)
                | ((((long) b[offset + 1]) & 0xFF) << 48) | ((((long) b[offset]) & 0xFF) << 56));
    }
}

Related

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