Java Number Range Check rangeCheck(double value)

Here you can find the source of rangeCheck(double value)

Description

Checks 0..1 range

License

Apache License

Exception

Parameter Description
IllegalArgumentException if range is wrong

Declaration

public static double rangeCheck(double value) 

Method Source Code

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

public class Main {
    /**/*from   ww w .j av a2s.c o  m*/
     * Checks 0..1 range
     *
     * @throws IllegalArgumentException if range is wrong
     */
    public static double rangeCheck(double value) {
        if ((value < 0.0) || (value > 1.0)) {
            throw new IllegalArgumentException(
                    "Humanity should been between 0.0 and 1.0!");
        } else {
            return value;
        }
    }
}

Related

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