Java Long to Byte Array longToBytes(byte[] arr, int offset, long num)

Here you can find the source of longToBytes(byte[] arr, int offset, long num)

Description

long To Bytes

License

Open Source License

Declaration

public static int longToBytes(byte[] arr, int offset, long num) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int longToBytes(byte[] arr, int offset, long num) {
        arr[offset + 0] = (byte) (num >> 56);
        arr[offset + 1] = (byte) (num >> 48);
        arr[offset + 2] = (byte) (num >> 40);
        arr[offset + 3] = (byte) (num >> 32);
        arr[offset + 4] = (byte) (num >> 24);
        arr[offset + 5] = (byte) (num >> 16);
        arr[offset + 6] = (byte) (num >> 8);
        arr[offset + 7] = (byte) (num >> 0);

        return 8;
    }//  w  ww  . ja  v  a 2s  . c  o  m
}

Related

  1. longToByteArray6(long addr)
  2. longToByteArray6(long addr)
  3. longToByteArrayBE(long data)
  4. longToByteArrayForAS(long i)
  5. longToByteBounds(long value)
  6. longToBytes(final long aLong)
  7. longToBytes(final long l)
  8. longToBytes(final long l)
  9. longToBytes(final long val)