Home » Java programming language

Java Math Class static double IEEEremainder(double divi , double divisor) with example

Java Math Class static double IEEEremainder(double divi , double divisor) method: Here, we are going to learn about the static double IEEEremainder(double divi , double divisor) method of Math Class with its syntax and example.
Submitted by Preeti Jain, on September 04, 2019

Math Class static double IEEEremainder(double divi , double divisor)

  • This method is available in java.lang package.
  • This method is used to return the calculated remainder on the given two parameters.
  • This method is followed by IEEE 754 Standard.
  • This is a static method so it is accessible with the class name too.
  • This method accepts two parameters (one is dividend and other is divisor), and it returns the two numbers (one is quotient and other is remainder).
  • Example: Let suppose if the dividend is fully divisible by divisor then the value of the remainder will be 0 and in that case, the resultant value sign will be the same as the sign of the first argument.
  • The return type of this method is double that means it returns the remainder of the given arguments.
  • In this method, we pass two parameters as arguments, where, the first argument represents the dividend and the second argument represents the divisor.
  • This method does not throw any exception.

Syntax:

    public static double IEEEremainder(double divi, double divisor){
    }

Parameter(s):

  • divi – the value of dividend.
  • divisor – the value of divisor.

Return value:

The return type of this method is double, it returns the remainder.

Note:

  • If we pass any argument "NaN", it returns the "NaN".
  • If we pass any argument as an infinity, it returns the "NaN".
  • If we pass any argument as 0 (-0 or 0), it returns the "NaN".
  • If we pass a finite value as a first argument and an infinite value as second argument, it returns the first argument.

Java program to demonstrate example of IEEEremainder(double divi , double divisor) method

// Java program to demonstrate the example of 
// IEEEremainder(double divi, double divisor) method of Math Class

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

        // displaying values
        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("Math.IEEEremainder (d1,d2): " + Math.IEEEremainder(d1, d2));

        // Here , we will get (NaN) because we are passing 
        // second parameter whose value is (positive or negative 0)
        System.out.println("Math.IEEEremainder (d2,d4): " + Math.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("Math.IEEEremainder (d2,d1): " + Math.IEEEremainder(d2, d1));

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

    }
}

Output

E:\Programs>javac HypotMethod.java

E:\Programs>java HypotMethod
d1: Infinity
d2: 10.0
d3: 5.0
d4: 0.0
d5: -0.0
Math.IEEEremainder (d1,d2): NaN
Math.IEEEremainder (d2,d4): NaN
Math.IEEEremainder (d2,d1): 10.0
Math.IEEEremainder (d2,d3): 0.0



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.