Java Long Number From longFromBytes(byte[] bytes, int offset)

Here you can find the source of longFromBytes(byte[] bytes, int offset)

Description

long From Bytes

License

Open Source License

Declaration

public static long longFromBytes(byte[] bytes, int offset) 

Method Source Code

//package com.java2s;
/*//from w  w  w.  j  a  v a2 s .com
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2013 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

public class Main {
    public static long longFromBytes(byte[] bytes, int offset) {
        long ret = 0;
        ret |= (bytes[offset + 0] & 0xFFL) << 56;
        ret |= (bytes[offset + 1] & 0xFFL) << 48;
        ret |= (bytes[offset + 2] & 0xFFL) << 40;
        ret |= (bytes[offset + 3] & 0xFFL) << 32;
        ret |= (bytes[offset + 4] & 0xFFL) << 24;
        ret |= (bytes[offset + 5] & 0xFFL) << 16;
        ret |= (bytes[offset + 6] & 0xFFL) << 8;
        ret |= (bytes[offset + 7] & 0xFFL);
        return ret;
    }
}

Related

  1. longFromByteArray(final byte[] buf, final int offset)
  2. longFromBytes(byte b8, byte b7, byte b6, byte b5, byte b4, byte b3, byte b2, byte b1)
  3. longFrombytes(byte[] b, int pos)
  4. longFromBytes(byte[] buffer, int offset)
  5. longFromBytes(byte[] bytes, int index)
  6. longFromDB(String dbLong)
  7. longFromLex(byte[] bytes)
  8. longFromObject(Object o)
  9. toLongAsObject(Object obj)