Utility function which transfers a long to a byte array in big endian format.
187339
public static byte[] longToBytes(long rmid)
    {
        return new byte[] { (byte)(rmid>>56), (byte)(rmid>>48), (byte)(rmid>>40), (byte)(rmid>>32),
                            (byte)(rmid>>24), (byte)(rmid>>16), (byte)(rmid>>8), (byte)(rmid)};
    }
714312
def _encode_long(name, value, dummy0, dummy1):
    """"""
    try:
        return b"\x12" + name + _PACK_LONG(value)
    except struct.error:
        raise OverflowError("BSON can only handle up to 8-byte ints")
194843
public static byte[] toBytes(long value) {
        byte[] bytes = new byte[8];
        ByteBuffer buffer = ByteBuffer.wrap(bytes);
        buffer.putLong(value);
        return bytes;
    }
26252
public static long toLong(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return (toInt(b, off, LITTLE_ENDIAN) & 0xFFFFFFFFL) |
					((toInt(b, off + 4, LITTLE_ENDIAN) & 0xFFFFFFFFL) << 32);
		}
		return ((toInt(b, off, BIG_ENDIAN) & 0xFFFFFFFFL) << 32) |
				(toInt(b, off + 4, BIG_ENDIAN) & 0xFFFFFFFFL);
	}
1095911
static long toLong(final byte[] buffer, final int offset) {
        final long value1 = toInt(buffer, offset);
        final long value2 = toInt(buffer, offset + 4);
        return (value1 << 32) + ((value2 << 32) >>> 32);
    }
1222298
public static long bytesToLongPad(byte[] bytes) {
        final int padZeros = Math.max(8-bytes.length, 0);
        ByteBuffer bb = ByteBuffer.allocate(8);
        for(int i=0; i<padZeros; i++) {
            bb.put((byte)0);
        }
        bb.put(bytes, 0, 8-padZeros);
        bb.flip();
        return bb.getLong();
    }
23913
public static final long getLong(byte[] data, int offset)
   {
      long result = 0;
      int i = offset;
      for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
      {
         result |= ((long) (data[i] & 0xff)) << shiftBy;
         ++i;
      }
      return result;
   }
1152244
public static long bytes_to_uint(byte[] bytes, int offset) {
		if(bytes.length-offset<4)
			throw new PickleException("too few bytes to convert to long");
		long i = bytes[3+offset] & 0xff;
		i <<= 8;
		i |= bytes[2+offset] & 0xff;
		i <<= 8;
		i |= bytes[1+offset] & 0xff;
		i <<= 8;
		i |= bytes[0+offset] & 0xff;
		return i;
	}
244755
def write_long(self, n, pack=Struct('>I').pack):
        
        if 0 <= n <= 0xFFFFFFFF:
            self._output_buffer.extend(pack(n))
        else:
            raise ValueError('Long %d out of range 0..0xFFFFFFFF', n)
        return self
1096132
def field_to_long(value):
        
        if isinstance(value, (int, long)):
            return long(value)
        elif isinstance(value, basestring):
            return bytes_to_long(from_hex(value))
        else:
            return None
871451
public static long readLong(byte[] buf, int pos) {
    checkBoundary(buf, pos, 8);
    return (((long) (buf[pos++] & 0xff) << 56) | ((long) (buf[pos++] & 0xff) << 48)
        | ((long) (buf[pos++] & 0xff) << 40) | ((long) (buf[pos++] & 0xff) << 32)
        | ((long) (buf[pos++] & 0xff) << 24) | ((long) (buf[pos++] & 0xff) << 16)
        | ((long) (buf[pos++] & 0xff) << 8) | ((long) (buf[pos] & 0xff)));
  }
756259
private int getLengthFromByteArray(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getShort();
    }
39532
public static long byteArrayToLongLE( byte[] data ) {
        if (data == null)
            return 0x0;
        long accum = 0;
        int shiftBy = 0;
        for( byte b : data ) {
            accum |= (long) (b & 0xff) << shiftBy;
            shiftBy += 8;
        }
        return accum;
    }
1363828
public static long getLong(ByteBuffer buf, int index) {
        return buf.order() == BIG_ENDIAN ? getLongB(buf, index) : getLongL(buf, index);
    }
1459
long[] toLongArray() {
		// create array through an aligned copy
		BitVector copy = alignedCopy();
		long[] longs = copy.bits;
		int length = longs.length;
		if (length == 0) return longs;
		// reverse the array
		for (int i = 0, mid = length >> 1, j = length - 1; i < mid; i++, j--) {
			long t = longs[i];
			longs[i] = longs[j];
			longs[j] = t;
		}
		// mask off top bits in case copy was produced via clone
		final long mask = -1L >>> (ADDRESS_SIZE - copy.finish & ADDRESS_MASK);
		longs[0] &= mask;
		// return the result
		return longs;
	}
366570
public static long readLong(byte[] bytes, int start) {
        return ((long) (readInt(bytes, start)) << 32) +
            (readInt(bytes, start + 4) & 0xFFFFFFFFL);
    }
255313
public static void writeLong(byte b[], int offset, long value) {
    b[offset++] = (byte) (value >>> 56);
    b[offset++] = (byte) (value >>> 48);
    b[offset++] = (byte) (value >>> 40);
    b[offset++] = (byte) (value >>> 32);
    b[offset++] = (byte) (value >>> 24);
    b[offset++] = (byte) (value >>> 16);
    b[offset++] = (byte) (value >>> 8);
    b[offset] = (byte)value;
  }