Java Double Number Clip clip(double v, double min, double max)

Here you can find the source of clip(double v, double min, double max)

Description

Limits the range of v to be between min and max.

License

Open Source License

Declaration

public static double clip(double v, 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 a 2 s.co m*/
     * Limits the range of v to be between min and max.
     */
    public static double clip(double v, double min, double max) {
        if (v < min)
            return min;
        if (v > max)
            return max;
        return v;
    }

    /**
     * Limits the range of v to be between min and max.
     */
    public static int clip(int v, int min, int max) {
        if (v < min)
            return min;
        if (v > max)
            return max;
        return v;
    }
}

Related

  1. clip(double value, double min, double max)
  2. clip(double value, double min, double max)
  3. clip(double[] values, double min, double max)
  4. clip(final double n, final double minValue, final double maxValue)