Java Float Number Convert to convertFloatDouble(float[] in)

Here you can find the source of convertFloatDouble(float[] in)

Description

Convert a 1-D float array to double []

License

Open Source License

Parameter

Parameter Description
in the input array

Return

input array cast as doubles

Declaration

public static double[] convertFloatDouble(float[] in) 

Method Source Code

//package com.java2s;
/** Implement various functionality for working with arrays and Lists
 *
 * @package SciTK//from  w  w  w .  java 2 s .  c o m
 * @class ArrayUtil
 * @brief Convert arrays
 * @author Alex Zylstra
 * @date 2013/04/15
 * @copyright Alex Zylstra
 * @license SciTK / MIT License
 */

public class Main {
    /**
    * Convert a 1-D float array to double []
    * @param in the input array
    * @return input array cast as doubles
    */
    public static double[] convertFloatDouble(float[] in) {
        // need to explicitly convert each item:
        double[] out = new double[in.length];
        for (int i = 0; i < out.length; i++) {
            out[i] = (double) in[i];
        }

        return out;
    }

    /**
    * Convert a 2-D float array to double [][]
    * @param in the input array
    * @return input array cast as doubles
    */
    public static double[][] convertFloatDouble(float[][] in) {
        // need to explicitly convert each item:
        double[][] out = new double[in.length][in[0].length];
        for (int i = 0; i < out.length; i++) {
            for (int j = 0; j < out[i].length; j++) {
                out[i][j] = (double) in[i][j];
            }
        }

        return out;
    }

    /**
    * Convert a 3-D float array to double [][]
    * @param in the input array
    * @return input array cast as doubles
    */
    public static double[][][] convertFloatDouble(float[][][] in) {
        // need to explicitly convert each item:
        double[][][] out = new double[in.length][in[0].length][in[0][0].length];
        for (int i = 0; i < out.length; i++) {
            for (int j = 0; j < out[i].length; j++) {
                for (int k = 0; k < out[i][j].length; k++) {
                    out[i][j][k] = (double) in[i][j][k];
                }
            }
        }

        return out;
    }
}

Related

  1. convertFloat(float amount, boolean speech)
  2. convertFloat(String str, float defaults)
  3. convertFloatArray(float[] arr)
  4. convertFloatArrayToString(float[] value, String separator)
  5. convertFloatBitsToHFloat(final int floatBits)
  6. convertFloatFromBytes(byte[] byteArray)
  7. convertFloatFromStream(byte[] stream, int intStart, int decStart, int intNumbers, int decNumbers)
  8. convertFloatMatrixToDoubles(float[][] input, int dimRows, int dimColoumns)
  9. convertFloatsToFixed(float[] values)