Java Double Number Clamp clamp(double v, double lower, double upper)

Here you can find the source of clamp(double v, double lower, double upper)

Description

Clamp the value v to lower and upper.

License

Open Source License

Parameter

Parameter Description
v the value to clamp.
lower The lower bound.
upper The upper bound.

Return

The clamped value.

Declaration

public static double clamp(double v, double lower, double upper) 

Method Source Code

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

public class Main {
    /**//from w ww . j  a  v a2 s . com
     * Clamp the value v to lower and upper.
     * @param v the value to clamp.
     * @param lower The lower bound.
     * @param upper The upper bound.
     * @return The clamped value.
     */
    public static double clamp(double v, double lower, double upper) {
        return v < lower ? lower : v > upper ? upper : v;
    }
}

Related

  1. clamp(double min, double max, double val)
  2. clamp(double min, double max, double value)
  3. clamp(double min, double value, double max)
  4. clamp(double number)
  5. clamp(double v, double l, double h)
  6. clamp(double v, double lower, double upper)
  7. clamp(double val)
  8. clamp(double val)
  9. clamp(double val, double min, double max)