Java Integer to intToEightByte(long value, byte[] dest, int off)

Here you can find the source of intToEightByte(long value, byte[] dest, int off)

Description

int To Eight Byte

License

Open Source License

Declaration

public static void intToEightByte(long value, byte[] dest, int off) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String ERR_VALUE_OOB = "Value out of bounds (%s)";
    public static final long MAX_32BITS = 4294967295L;

    public static byte[] intToEightByte(long value) {
        byte[] buf = new byte[8];
        intToEightByte(value, buf, 0);// w ww .j a v  a  2 s  . c o m
        return buf;
    }

    public static void intToEightByte(long value, byte[] dest, int off) {
        long val1 = (value & 0xFFFFFFFF00000000L) >>> 32;
        long val2 = (value & 0x00000000FFFFFFFFL);
        intToFourByte(val1, dest, 0 + off);
        intToFourByte(val2, dest, 4 + off);
    }

    public static byte[] intToFourByte(long value) {
        byte[] buf = new byte[4];
        intToFourByte(value, buf, 0);
        return buf;
    }

    public static void intToFourByte(long value, byte[] dest, int off) {
        if ((value < 0) || (value > MAX_32BITS))
            throw new IllegalArgumentException(String.format(ERR_VALUE_OOB, value));

        dest[off + 0] = (byte) ((value & 0xFF000000L) >> 24);
        dest[off + 1] = (byte) ((value & 0x00FF0000L) >> 16);
        dest[off + 2] = (byte) ((value & 0x0000FF00L) >> 8);
        dest[off + 3] = (byte) ((value & 0x000000FFL));
    }
}

Related

  1. intToDigits(int n)
  2. intToDouble(int coordinate)
  3. intToDouble(int[] input)
  4. intToDouble100000(int i)
  5. intToDoubleArray(int[] labels)
  6. intToEightHexString(final int value)
  7. intToEle(int integEle)
  8. intToEncodedID(int input)
  9. IntToEnode62(Integer int10)