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:

1 2 3 4 |
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 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, Math.IEEEremainder will return the result as.**NaN** - If 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**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
//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**

First, We declared variable **a** of type Double and used the Java Math.IEEEremainder function directly on expression. Here, we used * System.out.println* statement to print the result as output.

1 2 |
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.

1 2 |
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)); |

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

1 2 |
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.

1 2 |
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

## Share your Feedback, or Code!!