Java Double to Byte double2byte(double d)

Here you can find the source of double2byte(double d)

Description

doublebyte

License

Open Source License

Declaration

public static final byte[] double2byte(double d) 

Method Source Code

//package com.java2s;

public class Main {
    public static final byte[] double2byte(double d) {
        byte dest[] = new byte[8];
        return setdouble(dest, 0, d);
    }//from  www. ja  v  a 2s .c  o m

    public static final byte[] setdouble(byte dest[], int offset, double d) {
        return setlong(dest, offset, Double.doubleToLongBits(d));
    }

    public static final byte[] setlong(byte dest[], int offset, long l) {
        setint(dest, offset, (int) (l >>> 32));
        setint(dest, offset + 4, (int) (l & 0xffffffffL));
        return dest;
    }

    public static final byte[] setint(byte dest[], int offset, int i) {
        dest[offset] = (byte) (i >>> 24 & 0xff);
        dest[offset + 1] = (byte) (i >>> 16 & 0xff);
        dest[offset + 2] = (byte) (i >>> 8 & 0xff);
        dest[offset + 3] = (byte) (i & 0xff);
        return dest;
    }
}

Related

  1. double2byte(double d)
  2. Double2Byte(double i)
  3. doubleToByte(double d)
  4. doubleToByte(double d)
  5. doubleToByte(double d)