Java Utililty Methods Integer Clamp

List of utility methods to do Integer Clamp

Description

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

Method

intclamp(int value, int min, int max)
clamp
if (value < min) {
    return min;
if (value > max) {
    return max;
return value;
intclamp(int value, int min, int max)
clamp
if (value < min)
    return min;
if (value > max)
    return max;
return value;
intclamp(int value, int min, int max)
Clamps the value to a discrete value
if (value < min)
    value = min;
if (value > max)
    value = max;
return value;
intclamp(int value, int min, int max)
Clamp Integer values to a given range
return Math.max(min, Math.min(max, value));
intclamp(int value, int min, int max)
clamp
int clamped = min > value ? min : value;
return max < clamped ? max : clamped;
intclamp(int value, int min, int max)
Clamp the provided value to the range specified by [min, max]
if (min > max) {
    return clamp(value, max, min);
return Math.max(min, Math.min(max, value));
intclamp(int value, int min, int max)
Fix a value between an interval.
final int fixed;
if (value < min) {
    fixed = min;
} else if (value > max) {
    fixed = max;
} else {
    fixed = value;
return fixed;
intclamp(int value, int minValue, int maxValue)
Limit an integer value to a specific range.
return Math.max(minValue, Math.min(value, maxValue));
intclamp(int var, int min, int max)
Clamp a value, I.E.
if (var >= max) {
    return max;
} else if (var <= min) {
    return min;
} else {
    return var;
intclamp(int x, int min, int max)
Clamps an int value to a given range.
if (x < min)
    return min;
if (x > max)
    return max;
return x;