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

Clamps a value to the range [lower, upper].

License

Apache License

Declaration

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

Method Source Code

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

public class Main {
    /**//  ww  w  .j a  v  a 2  s.  c o  m
     * Clamps a value to the range [lower, upper].
     */
    public static double clamp(double v, double lower, double upper) {
        if (v < lower)
            return lower;
        else if (v > upper)
            return upper;
        else
            return v;
    }
}

Related

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