Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Converts the given primative <code>double</code> array to a primitive <code>float</code> array
     * 
     * @param in
     *            a primative <code>double</code> array
     * 
     * @return a <code>float</code> array equivalent to the specified <code>double</code> array
     */
    public static float[] doubleArrayToFloatArray(double[] in) {
        float[] out = new float[in.length];
        for (int i = 0; i < in.length; i++) {
            if (Double.isNaN(in[i])) {
                out[i] = Float.NaN;
            } else {
                out[i] = (float) in[i];
            }
        }
        return out;
    }

    public static float[][] doubleArrayToFloatArray(double[][] in) {
        float[][] out = new float[in.length][];
        for (int i = 0; i < in.length; i++) {
            out[i] = doubleArrayToFloatArray(in[i]);
        }
        return out;
    }
}