Java Long to Byte Array longToByteArrayForAS(long i)

Here you can find the source of longToByteArrayForAS(long i)

Description

long To Byte Array For AS

License

Apache License

Declaration

public static byte[] longToByteArrayForAS(long i) 

Method Source Code

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

public class Main {

    public static byte[] longToByteArrayForAS(long i) {
        int h = (int) (i / 100000000);
        int l = (int) (i % 100000000);

        byte[] result = new byte[8];
        result[0] = (byte) ((h >> 24) & 0xFF);
        result[1] = (byte) ((h >> 16) & 0xFF);
        result[2] = (byte) ((h >> 8) & 0xFF);
        result[3] = (byte) (h & 0xFF);

        result[4] = (byte) ((l >> 24) & 0xFF);
        result[5] = (byte) ((l >> 16) & 0xFF);
        result[6] = (byte) ((l >> 8) & 0xFF);
        result[7] = (byte) (l & 0xFF);

        return result;
    }/*  ww  w. j  a va  2 s .  c om*/
}

Related

  1. longToByteArray(long value, byte[] dest)
  2. longToByteArray(long value, int nrOfBytes)
  3. longToByteArray6(long addr)
  4. longToByteArray6(long addr)
  5. longToByteArrayBE(long data)
  6. longToByteBounds(long value)
  7. longToBytes(byte[] arr, int offset, long num)
  8. longToBytes(final long aLong)
  9. longToBytes(final long l)