private static byte[] toBytes(final double[] values, final int offset, final int length, final ByteOrder byteOrder) {
        final byte[] result = Allocator.byteArray(length * 8);
        for (int i = 0; i < length; i++) {
            toBytes(values[offset + i], byteOrder, result, i * 8);
        }
        return result;
    }
Convenience methods for converting data types to and from byte arrays.
src/main/java/org/apache/commons/imaging/common/ByteConversions.java