Java Number Min Value findMin(double newNumber, double currentMin)

Here you can find the source of findMin(double newNumber, double currentMin)

Description

Return the min between 2 numbers.

License

Open Source License

Parameter

Parameter Description

Return

the min between the 2 numbers.

Declaration

public static double findMin(double newNumber, double currentMin) 

Method Source Code

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

public class Main {
    /**/*  w w w. ja v a  2s  .  c om*/
     * Return the min between 2 numbers. If the
     * current min is initialized as NaN, it automatically
     * sets as min the new number.
     * @param newNumber, the number we are going to compare against the existing
     * min.
     * @param currentMin, the existing min, can be initialized as Double.NaN
     * if it doesn't exist yet.
     * @return the min between the 2 numbers.
     */
    public static double findMin(double newNumber, double currentMin) {
        return Double.isNaN(currentMin) ? newNumber : currentMin > newNumber ? currentMin : newNumber;
    }
}

Related

  1. findMin(int a, int b, int c, int d)
  2. findMinAngularDistance(double angle1, double angle2)
  3. min( final double p_first, final double p_second, final double p_third )
  4. min(Comparable c1, Comparable c2)