×

Java Integer remainder Unsigned() method

The remainderUnsigned() method of Java Integer class returns the unsigned remainder by dividing the first and second argument. Syntax public static int remainderUnsigned(int dividend, int divisor)  Parameters The ‘dividend’ and ‘divisor’ represents the value to be divided and the value doing the dividing.  Return Value This method returns an unsigned remainder by dividing the dividend with divisor. Example 1
public class JavaIntegerRemainderUnsignedExample1 {
    public static void main(String[] args) {
      Integer dividend=120;
      Integer divisor=7;
      int quotient= Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+" = "+quotient);
      int remainder= Integer.remainderUnsigned(dividend,divisor);
        System.out.println("Remainder = "+remainder);
    }
}
Output
12/7 = 1
Remainder = 5
Example 2
public class JavaIntegerRemainderUnsignedExample2 {
    public static void main(String[] args) {
        Integer dividend=Integer.MAX_VALUE;
        Integer divisor=Integer.MIN_VALUE;
        // returns the MAX_VALUE if MAX_VALUE and MIN_VALUE are divided
        int quotient= Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+" = "+quotient);
        int remainder= Integer.remainderUnsigned(dividend,divisor);
        System.out.println("Remainder = "+remainder);
    }
}
Output
2147483647/-2147483648 = 0
Remainder = 2147483647
Example 3
public class JavaIntegerRemainderUnsignedExample3 {
    public static void main(String[] args) {
        Integer dividend=Integer.MAX_VALUE;
        Integer divisor=0;
        // Gives an exception if divisor is 0
        int quotient= Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+" = "+quotient);
        int remainder= Integer.remainderUnsigned(dividend,divisor);
        System.out.println("Remainder = "+remainder);
    }
}
Output
Exception in thread "main" java.lang.ArithmeticException: / by zero

              at java.lang.Integer.divideUnsigned(Integer.java:1294)

              at com.TutorialAndExample.JavaIntegerRemainderUnsignedExample3.main(JavaIntegerRemainderUnsignedExample3.java:8)

Related Topics

Check if the given array is mirror inverse in Java

The primary objective is to check whether the given array is mirror inverse or not. The values and position of the specified array are switched, and a duplicate array is created....

3 minutes read.

HashMap Vs HashTable

HashMap HashMap is the basic implementation of the map interface in Java. HashMap stores the data in key and value pairs. Keys are used to access the value of the element. It...

5 minutes read.

Pangram Program in Java

If a string comprises all alphabet letters from A to Z or from a to z without regard to case, it is referred to as a pangram. Some examples of pangram...

3 minutes read.

Java Numbers

We use primitive data types like byte, int, long, double, etc to work with the numbers, When we need objects, we use wrapper class like Integer, Double, Long, Byte, etc....

2 minutes read.

How to Reduce Time Complexity in Java

What is time complexity?  The time complexity in java is given as the amount of time a program requires to run or execute it Calculating the time complexity of the program The time...

4 minutes read.

Java Math exp() Method

The exp() method of Math class returns Euler’s number(e) raised to the power of a double value. Syntax: public static double exp(double a) Parameters: The parameter ‘a’ represents the exponent e. Return Value: The exp ()...

2 minutes read.

Compare time in java

Introduction: This article discusses how to compare time in java. Maximum of the time we need to examine the date and datetime items. Date comparisons are vital if you want to...

3 minutes read.

Java Program to Create Set of Pairs Using HashSet

HashSet in Java: HashSet is an assortment in Java that has a place with java.util bundle. It inside utilises HashMap to store components. It is an execution of the Set connection...

11 minutes read.

Java If Keyword

Definition: The if statement specifies a section of Java code that will run if an if statement's condition is false. The following conditional statements can be used in Java: To provide a block...

3 minutes read.

Block Swap Algorithm for array rotation in Java

An array and r, the rotation factor by which the array must be rotated, are both provided to us. We must then return the rotated array. A well-known and popular method is...

4 minutes read.

Java Integer parseUnsignedInt() method

The parseUnsignedInt() method of Java Integer class parses the string argument as an unsigned decimal integer. The second parameter parses the string argument as an unsigned integer in the radix specified...

2 minutes read.

Java Integer highestOneBit()

The highestOneBit() method of Java Integer class returns an int value with at most a single one-bit, in the position of the highest-order one-bit in the specified int value.  Syntax public static...

1 minute read.

Java Math sin() Method

The sin() method of Java Math class returns the trigonometric sine of the specified angle. Syntax: public static double sin(double a) Parameters: The parameter ‘a’ represents an angle measured in radians. Return Value: The sin() method...

1 minute read.

Java Thread Lifecycle: States and Stages

Multithreading Multithreading is one of the most important features in object-oriented programming, and this multithreading can be implemented by various object-oriented programming languages like Java, Python, and C++. A multithreaded process...

7 minutes read.

Zigzag Array in Java

In this tutorial, we discuss, what is zigzag array and its example. Even we will create the java program. In this program, we convert the simple array into a zigzag...

4 minutes read.

Automorphic Number Program in Java

We will learn about automorphic numbers through examples in this article, and we'll also make Java programmes that can determine whether a specific number was automorphic or not. What is an...

3 minutes read.

CopyOnWriteArrayList in Java

The CopyOnWriteArrayList is used to implement the List Interface. It is the improved version of ArrayList. The operations like add, remove, set, update etc, these operations are done by creating...

5 minutes read.

Java String Inbuilt functions

There are different types of inbuilt functions available in the Java String class, all of them are listed below. Char chat At (int index)It outputs the character indicated by the index....

5 minutes read.

Convert Integer to Roman Numerals in Java

The main objective of this article is to convert the integers that are decimal values to the roman numbers. Problem statement: Write a software/program/code to convert any integer to a roman number. You...

10 minutes read.

Heap Implementation in Java

The root node or parent node of a Java heap is compared to its left and right offspring, and the children are then ordered in line with the comparison.Assuming that...

9 minutes read.