Java Double Array to Byte Array doublesToBytes(final double[] array)

Here you can find the source of doublesToBytes(final double[] array)

Description

convert an array of double values to an array of byte .

License

Open Source License

Parameter

Parameter Description
array the array of double

Return

the array of byte

Declaration

public static final byte[] doublesToBytes(final double[] array) 

Method Source Code

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

public class Main {
    /**/*from   ww  w  .  j  a  v  a 2s  .c om*/
     * convert an array of {@code double} values to an array of {@code byte}.
     *
     * @param array
     *          the array of {@code double}
     * @return the array of {@code byte}
     */
    public static final byte[] doublesToBytes(final double[] array) {
        final byte[] res;
        int i;

        res = new byte[array.length];
        i = 0;
        for (final double x : array) {
            res[i++] = ((byte) x);
        }

        return res;
    }
}

Related

  1. doublesToBytes(double[] d)
  2. doublesToBytes(double[] doubles)