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 x, int min, int max)
clamp
if (x > max)
    return max;
if (x > min)
    return x;
return min;
Stringclamp(String string, int maxChars)
clamp
if (containsData(string) && string.length() > maxChars) {
    string = string.substring(0, maxChars) + "...";
return string;
intclamp_int(int num, int min, int max)
Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and third parameters.
return num < min ? min : (num > max ? max : num);
intclamp_wrap(int a, int x, int y)
Returns the given double clamped between the two values (wraps around if out of range).
return a < x ? y - (x - a) % (y - x) : a > y ? x + (a - y) % (y - x) : a;
intclampAngle(int angle)
Adjust the angle so that his value is in range [-180;180[
angle = angle % 360;
if (angle >= 180) {
    angle -= 360;
if (angle < -180) {
    angle += 360;
return angle;
...
byteclampByte(int in)
Clamps a number to the range supported by byte data type.
return (in > 0xFF ? (byte) 0xFF : (in >= 0 ? (byte) in : (byte) 0));
intclampColor(int c)
clamp Color
return c < 0 ? 0 : c > 255 ? 255 : c;
intclampColorInt(int color)
clamp Color Int
return (color < 0) ? 0 : (color > RGB_WHITE) ? RGB_WHITE : color;
intCLAMPED_Wr(long ITERW, int FBZCP)
CLAMPE Wr
int RESULT = (short) ((ITERW) >> 32);
if (!FBZCP_RGBZW_CLAMP(FBZCP)) {
    RESULT &= 0xffff;
    if (RESULT == 0xffff)
        RESULT = 0;
    else if (RESULT == 0x100)
        RESULT = 0xff;
    RESULT &= 0xff;
...
intclampI(int a, int min, int max)
clamp I
return a < min ? min : (a > max ? max : a);