# What are results of the Remainder Operator in Java?

The remainder operator % returns the remainder from the division of the left operand by the right operand;the left-hand operand is the dividend and the right-hand operand is the divisor.

In Java, the remainder operator % can be used with integral operands as well as floating-point operands ($15.17.3 Remainder Operator %).

For the integral type remainder operation whose operands are integers after binary numeric promotion, the remainder operator is defined by the following identity (if b is not 0): (a/b)*b + a%b = a

- If the divisor b evaluates to zero, then an ArithmeticException is thrown.
- If the dividend evaluates to zero, the result is zero.
- The sign of the result equals the sign of the dividend.
- The magnitude of the result |a%b| is always less than the magnitude of the divisor |b|.

The result of a floating-point remainder operation is determined by the rules

of IEEE arithmetic:

- If either operand is NaN, the result is NaN.
- If the result is not NaN, the sign of the result equals the sign of the dividend.
- If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN.
- If the dividend is finite and the divisor is an infinity, the result equals the dividend.
- If the dividend is a zero and the divisor is finite, the result equals the dividend.
- In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r from the division of a dividend n by a divisor d is defined by the mathematical relation r=n-(d*q) where q is an integer that is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of n and d.

### Most Recent java Faqs

- How to uncompress a file in the gzip format?
- How to make a gzip file in Java?
- How to use Java String.split method to split a string by dot?
- How to validate URL in Java?
- How to schedule a job in Java?
- How to return the content in the correct encoding from a servlet?
- What is the difference between JDK and JRE?

### Most Viewed java Faqs

- How to read input from console (keyboard) in Java?
- How to Retrieve Multiple Result Sets from a Stored Procedure in JDBC?
- How to Use Updatable ResultSet in JDBC?
- What are class variables in Java?
- What are local variables in Java?
- How to Use JDBC Java to Create Table?
- Why final variable in Enhanced for Loop does not act final?