Java.lang Package Classes

Java Long - divideUnsigned() Method



The java.lang.Long.divideUnsigned() method returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.

Syntax

public static long divideUnsigned(long dividend,
                                  long divisor)

Parameters

x Specify the value to be divided.
y Specify the value doing the dividing.

Return Value

Returns the unsigned quotient of the first argument divided by the second argument.

Exception

NA.

Example:

In the example below, the java.lang.Long.divideUnsigned() method returns the unsigned quotient of dividing given arguments.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating long values
    long x = 5;
    long y = 10;

    //printing quotient of dividing x by y 
    System.out.println("quotient of x/y: " + Long.divideUnsigned(x,y));

    //printing quotient of dividing y by x 
    System.out.println("quotient of y/x: " + Long.divideUnsigned(y,x)); 
  }
}

The output of the above code will be:

quotient of x/y: 0
quotient of y/x: 2

❮ Java.lang - Long