Java Utililty Methods Float Number Clamp

List of utility methods to do Float Number Clamp

Description

The list of methods to do Float Number Clamp are organized into topic(s).

Method

byteclampRoundByte(float in)
Clamps and rounds a number to the range supported by byte data type.
return (in > 0xFF ? (byte) 0xFF : (in >= 0 ? (byte) (in + 0.5F) : (byte) 0));
floatclampToMinusOneToOne(float value)
Clamps the given value to the -1..1 range.
if (value < -1) {
    value = -1;
if (value > 1) {
    value = 1;
return value;
floatclampToPositiveNonZero(float value)
Clamps the value to a positive non-zero value.
return Math.max(Float.MIN_VALUE, value);
floatclampTrigo(float value, float min, float max)
Clamp the given value to fit between the min and max values according to a trigonometric-like heuristic.
if (Float.isNaN(max)) { 
    return Float.NaN;
if (Float.isNaN(min)) {
    if (value > max)
        return max - Float.MAX_VALUE + value;
} else {
    assert (min <= max);
...
floatclampWithMod(float parFloat, float parMax)
clamp With Mod
return (parFloat + parMax) % parMax;
floatclampYaw(float yaw)
clamp Yaw
while (yaw < -180.0F) {
    yaw += 360.0F;
while (yaw >= 180.0F) {
    yaw -= 360.0F;
return yaw;
floatclampYaw(float yaw)
Ensure a yaw angle is between -180 and 180 degrees.
while (yaw > 180f)
    yaw -= 360f;
while (yaw < -180f)
    yaw += 360f;
return yaw;
floatclampZero_float(float value, float max)
clamp Zerfloat
return clampFloat(value, 0f, max);