Java StrictMath IEEEremainder() method with example

StrictMath Class IEEEremainder() method: Here, we are going to learn about the IEEEremainder() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 26, 2019

StrictMath Class IEEEremainder() method

• IEEEremainder() method is available in java.lang package.
• IEEEremainder() method is used to return the calculated remainder on the given two parameters.
• IEEEremainder() method is followed by IEEE 754 Standard.
• IEEEremainder() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
• As we all know that when we calculate the remainder so for that we need two numbers (one is dividend and other is divisor) and it also returns two numbers ( one is the quotient and other is remainder).
• Let suppose if the dividend is fully divisible by divisor then the value of remainder will be 0 and in that case, the resultant value sign will be the same as the sign of the first argument.
• IEEEremainder() method does not throw any exception.

Syntax:

```    public static double IEEEremainder(double divi, double divisor);
```

Parameter(s):

• double divi, double divisor – First argument represents the dividend and the second argument represents the divisor.

Return value:

The return type of this method is double – it returns the remainder of the given arguments.

Note:

• If we pass infinity in any of the arguments, method returns the NaN.
• If we pass NaN in any of the arguments, method returns NaN.
• If we pass 0 (negative or positive), method returns NaN.
• If we pass a finite value as the first argument and an infinite value as the second argument, method returns the first argument.

Example:

```// Java program to demonstrate the example of
// IEEEremainder(double divi, double divisor)
// method of StrictMath class.

public class IEEEremainder {
public static void main(String[] args) {
// variable declarations
Double d1 = 7.0 / 0.0;
Double d2 = 10.0;
Double d3 = 5.0;
Double d4 = 0.0;
Double d5 = -0.0;

// Display previous value of d1,d2,d3,d4 andd5
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
System.out.println("d4: " + d4);
System.out.println("d5: " + d5);

// Here , we will get (NaN) because we are
// passing first parameter whose value is (infinity)
System.out.println("StrictMath. IEEEremainder (d1,d2): " + StrictMath.IEEEremainder(d1, d2));

// Here , we will get (NaN) because we are passing
// second parameter whose value is (positive or negative 0)
System.out.println("StrictMath. IEEEremainder (d2,d4): " + StrictMath.IEEEremainder(d2, d4));

// Here , we will get (first argument) because we are
// passing finite parameter  as first argument whose value is (10.0)
// and passing infinity as second argument in the method.
System.out.println("StrictMath. IEEEremainder (d2,d1): " + StrictMath.IEEEremainder(d2, d1));

// Here , we will get (0.0) because we are passing
// parameter whose value is (10.0,5.0)
System.out.println("StrictMath. IEEEremainder (d2,d3): " + StrictMath.IEEEremainder(d2, d3));
}
}
```

Output

```d1: Infinity
d2: 10.0
d3: 5.0
d4: 0.0
d5: -0.0
StrictMath. IEEEremainder (d1,d2): NaN
StrictMath. IEEEremainder (d2,d4): NaN
StrictMath. IEEEremainder (d2,d1): 10.0
StrictMath. IEEEremainder (d2,d3): 0.0
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates