Java Array Max Value findMax(double newNumber, double currentMax)

Here you can find the source of findMax(double newNumber, double currentMax)

Description

Return the max between 2 numbers.

License

Open Source License

Parameter

Parameter Description

Return

the max between the 2 numbers.

Declaration

public static double findMax(double newNumber, double currentMax) 

Method Source Code

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

public class Main {
    /**/*www  .j  ava  2 s .  c  o  m*/
     * Return the max between 2 numbers. If the
     * current max is initialized as NaN, it automatically
     * sets as max the new number.
     * @param newNumber, the number we are going to compare against the existing
     * max.
     * @param currentMax, the existing max, can be initialized as Double.NaN
     * if it doesn't exist yet.
     * @return the max between the 2 numbers.
     */
    public static double findMax(double newNumber, double currentMax) {
        return Double.isNaN(currentMax) ? newNumber : currentMax > newNumber ? currentMax : newNumber;
    }
}

Related

  1. arrayMax(double[] arr)
  2. arrayMax(double[] x)
  3. arrayMax(final int[] array)
  4. arrayMax(int[] property)
  5. arrayMaximum(int[] array)
  6. findMax(double[] arr)
  7. findMax(double[] u, int startU, int length)
  8. findMax(double[] u, int startU, int length)
  9. findMax(double[] values)