Java Utililty Methods Double to Byte Array

List of utility methods to do Double to Byte Array

Description

The list of methods to do Double to Byte Array are organized into topic(s).

Method

byte[]doubleToByteArray(double value)
double To Byte Array
return longToByteArray(Double.doubleToRawLongBits(value));
byte[]doubleToByteArrayBE(double data)
Convert a double to a byte array (big endian).
return longToByteArrayBE(Double.doubleToRawLongBits(data));
byte[]doubleToBytes(double d)
This function converts a double to its corresponding byte array format.
byte[] buffer = new byte[8];
doubleToBytes(d, buffer, 0);
return buffer;
byte[]doubleToBytes(double d)
double To Bytes
long l = Double.doubleToRawLongBits(d);
byte[] r = new byte[8];
for (int i = 0; i < 8; i++) {
    r[i] = (byte) ((l >>> (i * 8)) & 0xFF);
return r;
byte[]doubleToBytes(double d)
double To Bytes
return longToBytes(Double.doubleToLongBits(d));
byte[]doubleToBytes(double d, byte[] bytes, int off, boolean bigEndian)
double To Bytes
return bigEndian ? doubleToBytesBE(d, bytes, off) : doubleToBytesLE(d, bytes, off);
voiddoubleToBytes(double d, byte[] data, int[] offset)
Write the bytes representing d into the byte array data, starting at index offset [0], and increment offset [0] by the number of bytes written; if data == null, increment offset [0] by the number of bytes that would have been written otherwise.
long bits = Double.doubleToLongBits(d);
longToBytes(bits, data, offset);
intdoubleToBytes(double dnum, byte[] bytes, int startIndex)
Given a double, convert it into a byte array
return longToBytes(Double.doubleToLongBits(dnum), bytes, startIndex);
voiddoubleToBytes(double v, byte[] bytes)
double To Bytes
doubleToBytes(v, bytes, 0);
voiddoubleToBytes(double v, byte[] bytes, int off)
double To Bytes
long el = Double.doubleToRawLongBits(v);
int shift = 64;
int lim = off + 8;
for (int i = off; i < lim; i++) {
    shift -= 8;
    bytes[i] = (byte) ((el >> shift) & 0xFF);