Java Array Min Value min(double[] values)

Here you can find the source of min(double[] values)

Description

Calculates the minimum over an given array of doubles.

License

Open Source License

Parameter

Parameter Description
values double array the minimum is calculated from

Return

minimum value of the given double array

Declaration

public static double min(double[] values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w w w . j  a v a 2 s . co  m
     * Calculates the minimum over an given array of doubles.
     * 
     * @param values
     *            double array the minimum is calculated from
     * @return minimum value of the given double array
     */
    public static double min(double[] values) {
        double min = values[0];
        for (double v : values) {
            if (v < min)
                min = v;
        }
        return min;
    }

    /**
     * Calculates the minimum over an given array of integers.
     * 
     * @param values
     *            integer array the minimum is calculated from
     * @return minimum value of the given integer array
     */
    public static int min(int[] values) {
        int min = values[0];
        for (int v : values) {
            if (v < min)
                min = v;
        }
        return min;
    }

    /**
     * Calculates the minimum over an given array of longs.
     * 
     * @param values
     *            long array the minimum is calculated from
     * @return minimum value of the given long array
     */
    public static long min(long[] values) {
        long min = values[0];
        for (long v : values) {
            if (v < min)
                min = v;
        }
        return min;
    }
}

Related

  1. min(double[] matrix)
  2. min(double[] numbers)
  3. min(double[] series)
  4. min(double[] vals)
  5. min(double[] values)
  6. min(double[] values)
  7. min(double[] x)
  8. min(final double... doubles)
  9. min(final Double... values)