Java Float Array Create toFloatArray(double[] doubleArray)

Here you can find the source of toFloatArray(double[] doubleArray)

Description

to Float Array

License

LGPL

Declaration

public static float[] toFloatArray(double[] doubleArray) 

Method Source Code

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

public class Main {
    public static float[] toFloatArray(double[] doubleArray) {
        float[] floatArray = new float[doubleArray.length];
        for (int i = 0; i < doubleArray.length; i++) {
            floatArray[i] = (float) doubleArray[i];
        }/*from   ww  w . j  ava 2 s . c o  m*/
        return floatArray;
    }

    public static float[] toFloatArray(double[][] doubleArray) {
        int w = doubleArray[0].length;
        int h = doubleArray.length;

        float[] floatArray = new float[w * h];
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                floatArray[j * w + i] = (float) doubleArray[j][i];
            }
        }
        return floatArray;
    }
}

Related

  1. floatArray(int len)
  2. toFloatArray(boolean[] array)
  3. toFloatArray(byte[] byteArray)
  4. toFloatArray(byte[] data)
  5. toFloatArray(byte[] data)
  6. toFloatArray(double[][] array)
  7. toFloatArray(final byte[] array)
  8. toFloatArray(final double[] doubleArray)
  9. toFloatArray(final Object[] array)