Java Float Number Create toFloat(double in1)

Here you can find the source of toFloat(double in1)

Description

Conversione da double a float

License

Open Source License

Parameter

Parameter Description
in1 a parameter

Declaration

public static float toFloat(double in1) 

Method Source Code

//package com.java2s;
/*/*from   ww w.j  a  v  a 2s  . co  m*/
 * Copyright (C) 2007 Alberto Duina, SPEDALI CIVILI DI BRESCIA, Brescia ITALY
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

public class Main {
    /***
     * Conversione da double a float
     * 
     * @param in1
     * @return
     */
    public static float toFloat(double in1) {
        return (float) in1;
    }

    public static float[] toFloat(double[] in1) {
        if (in1 == null)
            return null;
        float[] out1 = new float[in1.length];
        for (int i1 = 0; i1 < in1.length; i1++) {
            out1[i1] = (float) in1[i1];
        }
        return out1;
    }

    public static float[][] toFloat(double[][] in1) {
        if (in1 == null)
            return null;
        float[][] out1 = new float[in1.length][in1[0].length];
        for (int i1 = 0; i1 < in1.length; i1++) {
            for (int i2 = 0; i2 < in1[0].length; i2++) {
                out1[i1][i2] = (float) in1[i1][i2];
            }
        }
        return out1;
    }
}

Related

  1. toFloat(byte[] data)
  2. toFloat(byte[] data, int offset)
  3. toFloat(byte[] si, boolean isReverseOrder)
  4. toFloat(byte[] value)
  5. toFloat(byte[][] a)
  6. toFloat(double[] a)
  7. toFloat(double[] a)
  8. toFloat(double[] in)
  9. toFloat(double[] v)