Java Utililty Methods Double Number Clamp

List of utility methods to do Double Number Clamp

Description

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

Method

doubleclamp(double weight, double lowerBound, double upperBound)
clamp
if (weight > upperBound) {
    weight = upperBound;
} else if (weight < lowerBound) {
    weight = lowerBound;
return weight;
doubleclamp(double x, double low, double high)
Restrict x to the range [low, high].
return x < low ? low : (x > high ? high : x);
doubleclamp(double x, double min, double max)
clamp function.
return (x < min ? min : (x > max ? max : x));
doubleclamp(double x, double min, double max)
Returns x if it is within the specified range, or the closest value within the specified range if x is outside the range.
if (x < min) {
    return min;
} else if (x > max) {
    return max;
} else {
    return x;
doubleclamp(double x, double xMin, double xMax)
If x is between xMin and xMax, then return x; if x is less than xMin, then return xMin; if x is greater than xMax, then return xMax.
return (x < xMin) ? xMin : ((x > xMax) ? xMax : x);
doubleclamp(final double value, final double min, final double max)
clamp
if (min > max) {
    throw new IllegalArgumentException("min > max");
if (value < min) {
    return min;
} else if (value > max) {
    return max;
} else {
...
doubleclamp(final double value, final double min, final double max)
clamp
return Math.max(min, Math.min(max, value));
doubleclamp01(double d)
clamp
if (d < 0)
    d = 0;
else if (d > 1)
    d = 1;
return d;
doubleclamp01(double value)
clamp
return clamp(value, 0.0, 1.0);
intclamp255d(double d)
clampd
return clamp255((int) d);