Home >>Java Math Methods >Java Math.IEEEremainder() method

Java Math.IEEEremainder() method

Java Math.IEEEremainder() method

The Math. IEEEremainder() method in Java Math is used to measure the remaining operation on two arguments, as defined by the standard IEEE 754. The remaining value is mathematically equal to a-b, where n is the mathematical integer closest to the quotient a / b's exact mathematical value.

If a / b is equally closed to two integer then n is the integer that is even.

Syntax

public static double IEEEremainder(double a, double b)

Parameters

a = This parameter is used to the dividend

b = This parameter is used to the divisor

Returns

It is used to returns the remainder when a is divided by b.

  1. If the remaining two arguments are zero, then its sign is the same as the first argument's sign.
  2. If the first argument is infinite, then -1 returns the form.
  3. This method returns -1 if the second argument is positive or negative zero.
  4. This method will return -1 if any of the arguments is -1.
  5. If the first argument is finite and the second argument is infinite then the first argument value will be returned by this process.

Java Math.IEEEremainder() Method Example 1


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        double a = 123.1;  
        double b = 8.4;  
        System.out.println(Math.IEEEremainder(a, b));  
    }  
}  

Output:
-2.900000000000011

Java Math.IEEEremainder() Method Example 2


public class Main  
{  
    public static void main(String[] args)   
    {  
        double a = 2.0/0;  
        double b = 7;  
        System.out.println(Math.IEEEremainder(a, b));  
    }  
}  

Output:
NaN