floorMod(): This method is available in the Math class of Java.
Syntax:
int java.lang.Math.floorMod(long x, int y)
This method takes two arguments as its parameter first parameter is of type long and the second is of type int . This method returns the floor modulus of the long and int arguments.
Note:
1. The floor modulus is x - (floorDiv(x, y) * y),has the same sign as the divisor y, andis in the range of -abs(y) < r < +abs(y).
2.The relationship between floorDiv and floorMod is such that:
floorDiv(x, y)* y + floorMod(x, y) == x.
Parameters: Two parameters are required for this method.
x: the dividend.
y: the divisor
Returns:the floor modulus x - (floorDiv(x, y) * y)
Throws:ArithmeticException - if the divisor y is zero.
For Example:
Math.floorMod(1193932191,17) = > It returns 6.
Approach
Java
public class FloorModLong1 {public static void main(String[] args) {long x = 1193932191;int y = 17;System.out.println(Math.floorMod(x, y));}}
Output:
6
No comments:
Post a Comment