Java Double Array to Long Array doublesToLongs(final double[] array)

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

Description

convert an array of double values to an array of long .

License

Open Source License

Parameter

Parameter Description
array the array of double

Return

the array of long

Declaration

public static final long[] doublesToLongs(final double[] array) 

Method Source Code

//package com.java2s;
//License from project: MIT License 

public class Main {
    /**/*ww w .  ja  va  2 s .  c  om*/
     * convert an array of {@code double} values to an array of {@code long}.
     *
     * @param array
     *          the array of {@code double}
     * @return the array of {@code long}
     */
    public static final long[] doublesToLongs(final double[] array) {
        final long[] res;
        int i;

        res = new long[array.length];
        i = 0;
        for (final double x : array) {
            res[i++] = ((long) x);
        }

        return res;
    }
}