public static int floorMod(int x, int y) {
        int r = x - floorDiv(x, y) * y;
        return r;
    }
public static int floorMod ( int x , int y ) { int r = x - floorDiv ( x , y ) * y ; return r ; }
Returns the floor modulus of the {@code int} arguments.
<p>
The floor modulus is {@code x - (floorDiv(x, y) * y)},
has the same sign as the divisor {@code y}, and
is in the range of {@code -abs(y) < r < +abs(y)}.

<p>
The relationship between {@code floorDiv} and {@code floorMod} is such that:
<ul>
<li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
</ul>
<p>
The difference in values between {@code floorMod} and
the {@code %} operator is due to the difference between
{@code floorDiv} that returns the integer less than or equal to the quotient
and the {@code /} operator that returns the integer closest to zero.
<p>
Examples:
<ul>
<li>If the signs of the arguments are the same, the results
of {@code floorMod} and the {@code %} operator are the same.  <br>
<ul>
<li>{@code floorMod(4, 3) == 1}; &nbsp; and {@code (4 % 3) == 1}</li>
</ul>
<li>If the signs of the arguments are different, the results differ from the {@code %} operator.<br>
<ul>
<li>{@code floorMod(+4, -3) == -2}; &nbsp; and {@code (+4 % -3) == +1} </li>
<li>{@code floorMod(-4, +3) == +2}; &nbsp; and {@code (-4 % +3) == -1} </li>
<li>{@code floorMod(-4, -3) == -1}; &nbsp; and {@code (-4 % -3) == -1 } </li>
</ul>
</li>
</ul>
<p>
If the signs of arguments are unknown and a positive modulus
is needed it can be computed as {@code (floorMod(x, y) + abs(y)) % abs(y)}.

@param x the dividend
@param y the divisor
@return the floor modulus {@code x - (floorDiv(x, y) * y)}
@throws ArithmeticException if the divisor {@code y} is zero
@see #floorDiv(int, int)
@since 1.8