Java Double Number Create toDouble(short[] arr)

Here you can find the source of toDouble(short[] arr)

Description

Converts an array of short values to an array of double values.

License

Open Source License

Parameter

Parameter Description
arr a short array

Return

a double array

Declaration

public static double[] toDouble(short[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from w w w  . j  av a 2 s . c o m*/
     * Converts an array of short values to an array of double values. Returns a
     * new array.
     *
     * @param   arr a short array
     * @return  a double array
     */
    public static double[] toDouble(short[] arr) {
        int n = arr.length;
        double[] converted = new double[n];
        for (int i = 0; i < n; i++) {
            converted[i] = arr[i];
        }
        return converted;
    }

    /**
     * Converts an array of integer values to an array of double values. Returns 
     * a new array.
     *
     * @param   arr an integer array
     * @return  a double array
     */
    public static double[] toDouble(int[] arr) {
        int n = arr.length;
        double[] converted = new double[n];
        for (int i = 0; i < n; i++) {
            converted[i] = arr[i];
        }
        return converted;
    }

    /**
     * Converts an array of long values to an array of double values. Returns 
     * a new array.
     *
     * @param   arr a long array
     * @return  a double array
     */
    public static double[] toDouble(long[] arr) {
        int n = arr.length;
        double[] converted = new double[n];
        for (int i = 0; i < n; i++) {
            converted[i] = arr[i];
        }
        return converted;
    }

    /**
     * Converts an array of float values to an array of double values. Returns 
     * a new array.
     *
     * @param   arr a flaot array
     * @return  a double array
     */
    public static double[] toDouble(float[] arr) {
        int n = arr.length;
        double[] converted = new double[n];
        for (int i = 0; i < n; i++) {
            converted[i] = arr[i];
        }
        return converted;
    }
}

Related

  1. toDouble(Object value)
  2. toDouble(Object value)
  3. toDouble(Object value)
  4. toDouble(Object value, double nullValue)
  5. toDouble(Object x)
  6. toDouble(short[] src)
  7. toDouble(String aString)
  8. toDouble(String doubleString, Double defaultValue)
  9. toDouble(String input, double defaultValue)