Java Double Array to Float Array doublesToFloats(final double[] array)

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

Description

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

License

Open Source License

Parameter

Parameter Description
array the array of double

Return

the array of float

Declaration

public static final float[] doublesToFloats(final double[] array) 

Method Source Code

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

public class Main {
    /**//from   www.ja va  2s .c om
     * convert an array of {@code double} values to an array of {@code float}
     * .
     *
     * @param array
     *          the array of {@code double}
     * @return the array of {@code float}
     */
    public static final float[] doublesToFloats(final double[] array) {
        final float[] res;
        int i;

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

        return res;
    }
}

Related

  1. doublesToFloat(double[] array)