List of utility methods to do Integer Clamp
int | clampInt(final int min, final int max, final int value) clamp Int if ((value < min) || (value > max)) { if (value < min) { return min; } else if (value > max) { return max; return value; ... |
int | clampInt(final int min, final int value, final int max) Clamps an integer within the bounds [min, max] by setting it the the closest bound if it not within the range. return Math.min(max, Math.max(min, value));
|
int | clampInt(int value, int min, int max) Clamps an int between the given minimum and maximum values. return value < min ? min : value > max ? max : value;
|
int | clampInt(int value, int min, int max) clamp Int return (value < min) ? min : (value > max) ? max : value;
|
int | CLAMPIS(int a, int b, int c) CLAMPIS return a < b ? b : a > c ? c : a;
|
int | clampLoop(int v, int min, int max) clamp Loop if (min == max) return min; int range = max - min; if (v < min) v = max + 1 - ((min - v) % range); if (v > max) v = min - 1 + ((v - max) % range); return v; ... |
int | clampMono(int value) Clamp a mono audio sample to a valid range [-0x8000..0x7FFF]. return Math.max(Math.min(value, 0x7FFF), -0x8000);
|
int | clampNonNegative(int i, int a, int b) Returns i if i is between a and b , otherwise the boundary of [a..b]. if (a < 0) a = 0; if (b < 0) b = 0; if (b < a) { int tmp = a; a = b; b = tmp; ... |
int | clampPower(int num) clamp Power int initialCapacity = 1; if (num >= initialCapacity) { initialCapacity = num; initialCapacity |= (initialCapacity >>> 1); initialCapacity |= (initialCapacity >>> 2); initialCapacity |= (initialCapacity >>> 4); initialCapacity |= (initialCapacity >>> 8); initialCapacity |= (initialCapacity >>> 16); ... |
int | clampRGB(int val) Clamps an integer value between 0 and 255 if (val < 0) { return 0; } else if (val > 255) { return 255; return val; |