Java Utililty Methods Integer Mod

List of utility methods to do Integer Mod

Description

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

Method

intmod_diff(int x, int y, int R)
modiff
int dl = 0;
int dr = 0;
if (y > x) {
    dl = y - x;
    dr = x + R - y;
} else {
    dl = x - y;
    dr = y + R - x;
...
intmodByPowerOfTwo(int value, int mod)
mod By Power Of Two
return value & mod - 1;
intmodCeil(int x, int mod)
Rounds x up to a lowest number that is greater or equal to x and is divisible by mod.
return x + (mod - x % mod) % mod;
StringBuildermode(final StringBuilder buffer, final int mode)
Sets the text formatting mode.
buffer.append("\u001B[").append(mode).append('m');
return buffer;
intModEuclidean(int D, int d)
Mod Euclidean
int r = D % d;
if (r < 0) {
    if (d > 0) {
        r = r + d;
    } else {
        r = r - d;
return r;
intmodifyAlpha(int color, int alpha)
Set the alpha component of color to be alpha .
return (color & 0x00ffffff) | (alpha << 24);
StringmodifyBase32AtIndex(final String s, final int index)
Changes a single character in the specified base 32 string.
final char[] chars = s.toCharArray();
final char currentChar = chars[index];
char newChar = (char) (currentChar + 1);
switch (currentChar) {
case 'Z':
case '7':
    newChar = 'A';
chars[index] = newChar;
return new String(chars);
StringmodifyDummyString(String dummyString, int beginTag, int endTag)
modify Dummy String
String dummyStringInterval = createDummyString('*', endTag - beginTag);
return new String(dummyString.substring(0, beginTag) + dummyStringInterval
        + dummyString.substring(endTag, dummyString.length()));
booleanmodifyPublicPortCheckRange(String modifiedVal, int dashCnt)
modify Public Port Check Range
Boolean isPortValid = true;
try {
    if (dashCnt == 1) {
        String[] range = modifiedVal.split("-");
        int rngStart = Integer.parseInt(range[0]);
        int rngEnd = Integer.parseInt(range[1]);
        if (!(rngStart >= RANGE_MIN && rngStart <= RANGE_MAX && rngEnd >= RANGE_MIN
                && rngEnd <= RANGE_MAX)) {
...
StringmodifyString(char firstCharacter, String srcString, int indexOfSubstring)
modify String
return (indexOfSubstring < srcString.length()) ? firstCharacter + srcString.substring(indexOfSubstring)
        : String.valueOf(firstCharacter);