Java Double Number Clamp clamp(double value)

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

Description

Constraint the provided value to lie within [0..1] range.

License

Open Source License

Parameter

Parameter Description
value the value to check

Return

the adjusted value

Declaration

public static double clamp(double value) 

Method Source Code

//package com.java2s;
//  GNU Affero General Public License as published by the Free Software Foundation, either version

public class Main {
    /**//from   w  w w. j  a  v  a2s .c o  m
     * Constraint the provided value to lie within [0..1] range.
     *
     * @param value the value to check
     * @return the adjusted value
     */
    public static double clamp(double value) {
        if (value < 0) {
            value = 0;
        }

        if (value > 1) {
            value = 1;
        }

        return value;
    }
}

Related

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