Java Float Number Clamp clamp(float val, float min, float max)

Here you can find the source of clamp(float val, float min, float max)

Description

Clamps the given value between the min and max values

License

Open Source License

Parameter

Parameter Description
val The value to clamp
min Minimal value
max Maximal value

Declaration

public static float clamp(float val, float min, float max) 

Method Source Code

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

public class Main {
    /**//from   ww w . j a  v  a2s .c  o m
     * Clamps the given value between the min and max values
     * @param val The value to clamp
     * @param min Minimal value
     * @param max Maximal value
     */
    public static float clamp(float val, float min, float max) {
        if (val < min)
            return min;
        if (val > max)
            return max;
        return val;
    }
}

Related

  1. clamp(float num, float min, float max)
  2. clamp(float v)
  3. clamp(float v, float min, float max)
  4. clamp(float val, float low, float high)
  5. clamp(float val, float max, float min)
  6. clamp(float val, float min, float max)
  7. Clamp(float val, float minVal, float maxVal)
  8. clamp(float value)
  9. Clamp(float value, float lowerLimit, float upperLimit)