Java Double to Byte Array doubleToBytes(double d)

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

Description

double To Bytes

License

Apache License

Declaration

public static byte[] doubleToBytes(double d) 

Method Source Code

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

public class Main {
    public static byte[] doubleToBytes(double d) {
        return longToBytes(Double.doubleToLongBits(d));
    }/*from   w w w. j  a  va2s.  com*/

    public static byte[] longToBytes(long l) {
        byte[] b = new byte[8];
        b[0] = (byte) (l >>> 56);
        b[1] = (byte) (l >>> 48);
        b[2] = (byte) (l >>> 40);
        b[3] = (byte) (l >>> 32);
        b[4] = (byte) (l >>> 24);
        b[5] = (byte) (l >>> 16);
        b[6] = (byte) (l >>> 8);
        b[7] = (byte) (l);
        return b;
    }
}

Related

  1. doubleToByteArray(double number)
  2. doubleToByteArray(double source)
  3. doubleToByteArray(double value)
  4. doubleToByteArrayBE(double data)
  5. doubleToBytes(double d)
  6. doubleToBytes(double d)
  7. doubleToBytes(double d, byte[] bytes, int off, boolean bigEndian)
  8. doubleToBytes(double d, byte[] data, int[] offset)
  9. doubleToBytes(double dnum, byte[] bytes, int startIndex)