Java.lang Package Classes

Java Long - remainderUnsigned() Method



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

Syntax

public static long remainderUnsigned(long dividend,
                                     long divisor)

Parameters

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

Return Value

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

Exception

NA.

Example:

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

import java.lang.*;

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

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

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

The output of the above code will be:

remainder of x/y: 5
remainder of y/x: 3

❮ Java.lang - Long

5