floorDiv(); This method is available in the Math class of Java.
Syntax:
long java.lang.Math.floorDiv(long x, long y)
This method takes two parameters as an argument of type long. This method returns the largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.
Note: There is one special case if the dividend is the Long.MIN_VALUE and the divisor is -1, then integer overflow occurs and the result is equal to Long.MIN_VALUE.
Parameters: Two parameters are required for this method.
x: the dividend.
y: the divisor
Returns: the largest (closest to positive infinity) long value that is less than or equal to the algebraic quotient.
Note: It Throws: ArithmeticException - if the divisor y is zero.
For Example:
Math.floorDiv(1717717799,162629976) => It returns 10.
Approach
Java
public class FloorDivLong {public static void main(String[] args) {long x = 1717717799, y = 162629976;System.out.println(Math.floorDiv(x, y));}}
Output:
10
No comments:
Post a Comment