Java Number Range Check inrange2(double value, double min, double max)

Here you can find the source of inrange2(double value, double min, double max)

Description

checks if value is between min and max, inclusive.

License

Open Source License

Parameter

Parameter Description
value the value to check
min the minimal possible value
max the maximal possible value

Return

if value is between or equal to min and max

Declaration

public static boolean inrange2(double value, double min, double max) 

Method Source Code

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

public class Main {
    /**/*  w  w  w.j a  v a2 s. co  m*/
     * checks if value is between min and max, inclusive. automatically swaps min and max if needed
     * @param value the value to check
     * @param min the minimal possible value
     * @param max the maximal possible value
     * @return if value is between or equal to min and max
     */
    public static boolean inrange2(double value, double min, double max) {
        if (max < min) {
            double t = min;
            min = max;
            max = t;
        }
        return value <= max && value >= min;
    }
}

Related

  1. inRange(int value, int min, int max)
  2. inRange(int value, int min, int max)
  3. inRange(int x, int a, int b)
  4. inRange(Integer x1, Integer y1, Integer x2, Integer y2)
  5. inRange(long value, long lowerBound, long upperBound)
  6. rangeCheck(double value)
  7. rangeCheck(final C start, final C end, final C step)
  8. rangeCheck(final int value, final int min, final int max)
  9. rangeCheck(int arrayLen, int fromIndex, int toIndex)