Java Double Array to Int Array arrayDoubleToArrayInt(final double[] array)

Here you can find the source of arrayDoubleToArrayInt(final double[] array)

Description

converts an array of double in an array of int.

License

GNU General Public License

Parameter

Parameter Description
array Array of double to convert

Return

an array of int

Declaration

public static int[] arrayDoubleToArrayInt(final double[] array) 

Method Source Code

//package com.java2s;
/*/*from w w w. j  a v  a 2 s .c o  m*/
 *                      Nividic development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the microarray platform
 * of the ?cole Normale Sup?rieure and the individual authors.
 * These should be listed in @author doc comments.
 *
 * For more information on the Nividic project and its aims,
 * or to join the Nividic mailing list, visit the home page
 * at:
 *
 *      http://www.transcriptome.ens.fr/nividic
 *
 */

public class Main {
    /**
     * converts an array of double in an array of int.
     * @param array Array of double to convert
     * @return an array of int
     */
    public static int[] arrayDoubleToArrayInt(final double[] array) {

        if (array == null)
            return null;

        final int[] result = new int[array.length];
        final int n = array.length;

        for (int i = 0; i < n; i++) {
            result[i] = (int) array[i];
        }

        return result;
    }
}

Related

  1. doublesToInts(final double[] array)