Java Float Number Clamp clamp(final float value, final float min, final float max)

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

Description

Constrains a value between a min and a max

License

Open Source License

Parameter

Parameter Description
value Value to constrain
min Min value
max Max value

Return

Value constrained to between min and max

Declaration

public static float clamp(final float value, final float min, final float max) 

Method Source Code

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

public class Main {
    /**/*  w  w  w . j av a2s .c  o m*/
     * Constrains a value between a min and a max
     * @param value Value to constrain
     * @param min Min value
     * @param max Max value
     * @return Value constrained to between min and max
     */
    public static float clamp(final float value, final float min, final float max) {
        return (value < min) ? min : ((value > max) ? max : value);
    }
}

Related

  1. clamp(final float min, final float x, final float max)
  2. clamp(final float num, final float bound1, final float bound2)
  3. clamp(final float v, final float min, final float max)
  4. clamp(final float val, final float min, final float max)
  5. clamp(final float x, final float a, final float b)
  6. clamp(float a, float min, float max)
  7. Clamp(float a, float min, float max)
  8. clamp(float f)