Java Math floorMod() Method
Example
Return the remainders of rounded-down divisions:
System.out.println(Math.floorMod(10, 4));
System.out.println(Math.floorMod(-10, 4));
System.out.println(Math.floorMod(10, 3));
System.out.println(Math.floorMod(-10, 3));
Try it Yourself »
Definition and Usage
The floorMod()
method returns the remainder of a division between two integers where the result of the division was rounded down.
dividend - Math.floorDiv(dividend, divisor) * divisor
.
Syntax
One of the following:
public static int floorMod(int dividend, int divisor)
public static long floorMod(long dividend, long divisor)
Parameter Values
Parameter | Description |
---|---|
dividend | Required. The dividend of the remainder operation. |
divisor | Required. The divisor of the remainder operation. |
Technical Details
Returns: | An int or long value representing the remainder from a division between two integers. |
---|---|
Throws: | ArithmeticException - If the divisor is zero. |
Java version: | 1.8+ |
❮ Math Methods