Java Long to Byte Array LongToBytes8(long l)

Here you can find the source of LongToBytes8(long l)

Description

Long To Bytes

License

Apache License

Declaration

public static byte[] LongToBytes8(long l) 

Method Source Code

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

public class Main {
    public static byte[] LongToBytes8(long l) {
        byte abyte0[] = new byte[8];
        abyte0[7] = (byte) (int) (255L & l);
        abyte0[6] = (byte) (int) ((65280L & l) >> 8);
        abyte0[5] = (byte) (int) ((0xff0000L & l) >> 16);
        abyte0[4] = (byte) (int) ((0xff000000L & l) >> 24);
        abyte0[3] = (byte) (int) ((0xff00000000L & l) >> 32);
        abyte0[2] = (byte) (int) ((0xff0000000000L & l) >> 40);
        abyte0[1] = (byte) (int) ((0xff000000000000L & l) >> 48);
        abyte0[0] = (byte) (int) ((0xff00000000000000L & l) >> 56);
        return abyte0;
    }//w w  w.  ja va2  s .c  om
}

Related

  1. longToBytes(long value)
  2. longToBytes(long value, byte[] array, int offset)
  3. longToBytes(long value, byte[] buffer, int bufferStartPosition)
  4. longToBytes(long value, byte[] buffer, int offset)
  5. LongToBytes4(long l, byte abyte0[])
  6. LongToBytesLE(final long val)
  7. longToBytesLE(long value, byte[] buffer)
  8. longToBytesLE(long value, byte[] buffer, int offset, int length)
  9. longToBytesPlus8(byte[] p, long v)