Java Double to Float doubleToFloat(double[] array)

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

Description

Convert a double array to a float array.

License

Open Source License

Parameter

Parameter Description
array array of doubles to convert

Return

array of floats

Declaration

public static float[] doubleToFloat(double[] array) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w w  w .ja  v a2s.c o m
     * Convert a double array to a float array.
     * @param array array of doubles to convert
     * @return array of floats
     */
    public static float[] doubleToFloat(double[] array) {
        float[] farr = new float[array.length];

        for (int i = 0; i < array.length; i++) {
            farr[i] = (float) array[i];
        }
        return farr;
    }
}

Related

  1. doubleToFloat(double d)
  2. doubleToFloat(double[] array)
  3. doubleToFloat(final double value)