The Java IEEEremainder Function is one of the Java Math Library function and it is used to find the remainder of the two arguments as prescribed by the IEEE 754 standard.

In this article we will show you, How to write Math.IEEEremainder function in Java Programming language with example.

## Java IEEEremainder Function syntax

The basic syntax of the Math.IEEEremainder Function in Java Programming language is as shown below:

static double IEEEremainder(double x, double y); // Return Type is Double //In order to use in Java program use following code Math.IEEEremainder(double x, double y);

**x:**Please specify the dividend value here.**y:**Please specify the divisor value or power here.

The Java Math.IEEEremainder function will find the remainder of the two arguments. The remainder value is mathematically equal to x – y × *n*, where *n* is the integer closest to the exact mathematical value of the quotient x / y, and if two integers are equally close to x / y, then *n* is the integer that is even.

There are some special case where the result of the Java IEEEremainder will be different and they are:

- If the
*first argument*is infinite, Math.IEEEremainder will return the result as.**NaN** - If the
*second argument*is positive or negative zero, Java IEEEremainder will return the result as.**NaN** - When either the
*x*or*y*argument is not a Number, Java Math.IEEEremainder will return the result as.*NaN* - If the
*first argument*is finite and*second argument*is infinity, then Math.IEEEremainder will return the first argument value as result.

The return value is nothing but x Modulus y and if you find difficult to understand the modulus operator, Please visit Java Arithmetic Operators article. For example, 6 % 12 = 2

## Java IEEEremainder Function Example

The Java Math.IEEEremainder function is used to return the remainder of the given number.

In this example, We are going to find the remainder of both positive and negative double values and display the output

**JAVA CODE**

//Java Math.IEEEremainder Function package MathFunctions; public class IEEEremainderMethod { public static void main(String[] args) { // get the remainder when x/y -- Mod double a = Math.IEEEremainder((5.12 - 4.65 + 3.53), 3); System.out.println("Math.IEEEremainder Result = = " + a); System.out.println("\nMath.IEEEremainder Result for Zero as First argument = " + Math.IEEEremainder(0, 2)); System.out.println("Math.IEEEremainder Result for Zero as Second argument = " + Math.IEEEremainder(2, 0)); System.out.println("\nMath.IEEEremainder Result of Positive Number = " + Math.IEEEremainder(9, 8)); System.out.println("Math.IEEEremainder Result of Positive Number = " + Math.IEEEremainder(6, 12)); System.out.println("\nMath.IEEEremainder Result of Negative Number = " + Math.IEEEremainder(-98, 6)); System.out.println("Math.IEEEremainder Result of Negative Number = " + Math.IEEEremainder(164, -5)); } }

**OUTPUT**

**ANALYSIS**

Within this Java IEEEremainder function example, First, We declared variable **a** of type Double.

Next, we used the Java Math.IEEEremainder function directly on expression. Here, we used * System.out.println* statement to print the result as output.

double a = Math.IEEEremainder((5.12 - 4.65 + 3.53), 3); System.out.println("Math.IEEEremainder Result = = " + a);

From the above statement, Math.IEEEremainder((5.12 – 4.65 + 3.53), 3) ==> Math.IEEEremainder(4, 3) ==> 0.99 (~ 1)

Next, We used the Math.IEEEremainder Function with one positive double value and other argument as zero.

System.out.println("\nMath.IEEEremainder Result for Zero as First argument = " + Math.IEEEremainder(0, 2)); System.out.println("Math.IEEEremainder Result for Zero as Second argument = " + Math.IEEEremainder(2, 0));

Here, We used the Java IEEEremainder Function directly on Positive double values.

System.out.println("\nMath.IEEEremainder Result of Positive Number = " + Math.IEEEremainder(9, 8)); System.out.println("Math.IEEEremainder Result of Positive Number = " + Math.IEEEremainder(6, 12));

Next, We used the Math.IEEEremainder Function directly on Negative double values.

System.out.println("\nMath.IEEEremainder Result of Negative Number = " + Math.IEEEremainder(-98, 6)); System.out.println("Math.IEEEremainder Result of Negative Number = " + Math.IEEEremainder(164, -5));

Thank You for Visiting Our Blog