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

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

Description

Clamps a value between a min and a max, both inclusive.

License

Open Source License

Parameter

Parameter Description
min The minimum value.
x The value.
max The maximum value.

Return

The clamped value.

Declaration

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

Method Source Code

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

public class Main {
    /**//from  w w  w . ja  v a 2  s.  com
     * Clamps a value between a min and a max, both inclusive. Equivalent to
     * calling Math.min(max, Math.max(x, min)).
     * @param min The minimum value.
     * @param x The value.
     * @param max The maximum value.
     * @return The clamped value.
     */
    public static float clamp(float min, float x, float max) {
        return Math.min(max, Math.max(x, min));
    }
}

Related

  1. clamp(float f, float min, float max)
  2. clamp(float f, float min, float max)
  3. clamp(float input, float min, float max)
  4. clamp(float min, float max, float val)
  5. clamp(float min, float max, float value)
  6. clamp(float n, float minValue, float maxValue)
  7. clamp(float num, float min, float max)
  8. clamp(float v)
  9. clamp(float v, float min, float max)