Java Float Number Clamp clampZero_float(float value, float max)

Here you can find the source of clampZero_float(float value, float max)

Description

clamp Zerfloat

License

Open Source License

Parameter

Parameter Description
value = the number to clamp
max = maximum possible value

Return

a float clamped between 0 and max

Declaration

public static float clampZero_float(float value, float max) 

Method Source Code

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

public class Main {
    /**// w ww .j  a  v a  2 s . co m
     * @param value = the number to clamp
     * @param max   = maximum possible value
     * @return a float clamped between 0 and max
     */
    public static float clampZero_float(float value, float max) {
        return clampFloat(value, 0f, max);
    }

    /**
     * @param value = the number to clamp
     * @param max   = maximum possible value
     * @param min   = minimum possible value
     */
    public static float clampFloat(float value, float min, float max) {
        return (value < min) ? min : (value > max) ? max : value;
    }
}

Related

  1. clampToPositiveNonZero(float value)
  2. clampTrigo(float value, float min, float max)
  3. clampWithMod(float parFloat, float parMax)
  4. clampYaw(float yaw)
  5. clampYaw(float yaw)