Here you can find the source of toFloat(int[] array)
Parameter | Description |
---|---|
array | Integer array. |
public static float[] toFloat(int[] array)
//package com.java2s; // under the BSD license. The original license terms are given below: public class Main { /**//from w w w. ja v a2s .com * 1-D Integer array to float array. * @param array Integer array. * @return Float array. */ public static float[] toFloat(int[] array) { float[] n = new float[array.length]; for (int i = 0; i < array.length; i++) { n[i] = (float) array[i]; } return n; } /** * 2-D Integer array to float array. * @param array Integer array. * @return Float array. */ public static float[][] toFloat(int[][] array) { float[][] n = new float[array.length][array[0].length]; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[0].length; j++) { n[i][j] = (float) array[i][j]; } } return n; } /** * 1-D Double array to float array. * @param array Double array. * @return Float array. */ public static float[] toFloat(double[] array) { float[] n = new float[array.length]; for (int i = 0; i < array.length; i++) { n[i] = (float) array[i]; } return n; } /** * 2-D Double array to float array. * @param array Double array. * @return Float array. */ public static float[][] toFloat(double[][] array) { float[][] n = new float[array.length][array[0].length]; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[0].length; j++) { n[i][j] = (float) array[i][j]; } } return n; } }