Java Long Number Create fromLong(long value, byte[] arr, int offset)

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

Description

from Long

License

Apache License

Declaration

public static void fromLong(long value, byte[] arr, int offset) 

Method Source Code

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

public class Main {
    public static byte[] fromLong(long value) {
        byte[] arr = new byte[8];
        fromLong(value, arr, 0);/* w  w w  .ja v a 2 s  . c om*/
        return arr;
    }

    public static void fromLong(long value, byte[] arr, int offset) {
        value ^= 1L << 63;//toggling highest bit
        arr[offset] = (byte) (value >>> 56);
        arr[offset + 1] = (byte) (value >>> 48);
        arr[offset + 2] = (byte) (value >>> 40);
        arr[offset + 3] = (byte) (value >>> 32);
        arr[offset + 4] = (byte) (value >>> 24);
        arr[offset + 5] = (byte) (value >>> 16);
        arr[offset + 6] = (byte) (value >>> 8);
        arr[offset + 7] = (byte) value;
    }
}

Related

  1. convertLongFromBytes(byte[] bytes)
  2. convertLongitudeFromMercator( double mercatorLongitude)
  3. convertLongPriceToString(long price)
  4. convertLongtoMultiByte(long val)
  5. fromLong(byte[] buffer, int pos, long l)
  6. fromLongLE(byte src[], int offset, int numBytes)
  7. toLong(boolean b)
  8. toLong(boolean... a)
  9. toLong(byte b)