Java Double Number Create toDouble(int[] array)

Here you can find the source of toDouble(int[] array)

Description

1-D Integer array to double array.

License

BSD License

Parameter

Parameter Description
array Integer array.

Return

Double array.

Declaration

public static double[] toDouble(int[] array) 

Method Source Code

//package com.java2s;
// under the BSD license. The original license terms are given below:

public class Main {
    /**/*from   w  ww.ja  v a2s .  co m*/
     * 1-D Integer array to double array.
     * @param array Integer array.
     * @return Double array.
     */
    public static double[] toDouble(int[] array) {
        double[] n = new double[array.length];
        for (int i = 0; i < array.length; i++) {
            n[i] = (double) array[i];
        }
        return n;
    }

    /**
     * 2-D Integer array to double array.
     * @param array Integer array.
     * @return Double array.
     */
    public static double[][] toDouble(int[][] array) {
        double[][] n = new double[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] = (double) array[i][j];
            }
        }
        return n;
    }

    /**
     * 1-D Float array to double array.
     * @param array Float array.
     * @return Double array.
     */
    public static double[] toDouble(float[] array) {
        double[] n = new double[array.length];
        for (int i = 0; i < array.length; i++) {
            n[i] = (double) array[i];
        }
        return n;
    }

    /**
     * 2-D Float array to double array.
     * @param array Float array.
     * @return Double array.
     */
    public static double[][] toDouble(float[][] array) {
        double[][] n = new double[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] = (double) array[i][j];
            }
        }
        return n;
    }
}

Related

  1. toDouble(float[] v)
  2. toDouble(float[] val, int days, int start)
  3. toDouble(float[][] a)
  4. toDouble(int x)
  5. toDouble(int[] array)
  6. toDouble(int[] rgb)
  7. toDouble(int[][] arr)
  8. toDouble(Number n)
  9. toDouble(Number number)