Java Math IEEEremainder() Function

Java Math Class

Java Math class provides several methods to perform several operations on math calculations like max(), min(), sin(), cos(), round(), ceil(), floor(), IEEEremainder function etc.
The java.lang.Math class contains various methods for performing basic numeric operations

Here, in the page we will discuss about the IEEEremainder() Function in java.

Java IEEEremainder Function :

Java Collection contains Math class and The class Math contains methods for performing several basic and advance numeric operations such as the exponential, logarithm, square root, and trigonometric functions.
The IEEEremainder() method takes two arguments, say num1 and num2, and returns the remainder of the first argument i.e. num1, divided by the second argument i.e. num2 according to IEEE 754 standard.
It is a static function of java math class and can be accessed using the math class.

Syntax:

`Math.IEEEremainder(number1,number2);`

Return Type :

• If the remainder is 0, The IEEEremainder method will return 0.
• If the first argument is infinite, IEEEremainder method will return NaN.
• If the second argument is 0, IEEEremainder method will return NaN.
• If any of the argument is NaN, IEEEremainder method will return NaN.
• If the second argument is infinity, IEEEremainder method will return the first argument value.

Example :

Run
```import java.util.*;

public class Main{
public static void main(String[] args) {
double num1 = 9;
double num2 = 2;

// Storing the resultant
double ans = Math.IEEEremainder(num1,num2);

// Printing the remainder
System.out.println("Resultant Value : " + ans);
}
}```
```Output:

Resultant Value : 1.0
```

In the above Example, We had taken two double values. The IEEEremainder method returns the result of the first argument i.e. num1, divided by the second argument i.e. num2.

Example for Different Data Values:

Run
```import java.util.*;

public class Main{
public static void main(String[] args) {
// Integer variable
double num1 = 5.0;
double num2 = 3.0;

// resultant value for Integer value
System.out.println("Resultant value : " + Math.IEEEremainder(num1, num2));

// zero as argument
double num = 0.0;
System.out.println("Zero as Dividend : " + Math.IEEEremainder(num1, num));
System.out.println("Zero as Divisor : " + Math.IEEEremainder(num, num2));

// infinity as argument
num = Double.POSITIVE_INFINITY;
System.out.println("Infinity as Dividend : " + Math.IEEEremainder(num1, num));
System.out.println("Infinity as Divisor : " + Math.IEEEremainder(num, num2));

}
}```
```Output:

Resultant value : -1.0
Zero as Dividend : NaN
Zero as Divisor : 0.0
Infinity as Dividend : 5.0
Infinity as Divisor : NaN```

In the above Example, We had taken two arguments of Integer, zero, and infinity value. The IEEEremainder method will returns the result of the first argument i.e. num1, divided by the second argument i.e. num2.

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others