Java.lang.StrictMath.IEEEremainder() Method

Advertisements


Description

The java.lang.StrictMath.IEEEremainder() method computes the remainder operation on two arguments.

The remainder value is mathematically equal to f1 - f2 × n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even.

If the remainder is zero, its sign is the same as the sign of the first argument.It include some cases:

  • If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or negative zero, then the result is NaN.
  • If the first argument is finite and the second argument is infinite, then the result is the same as the first argument.

Declaration

Following is the declaration for java.lang.StrictMath.IEEEremainder() method

public static double IEEEremainder(double f1, double f2)

Parameters

  • f1 -- This is the dividend.

  • f2 -- This is the divisor.

Return Value

This method returns the remainder when f1 is divided by f2.

Exception

  • NA

Example

The following example shows the usage of java.lang.StrictMath.IEEEremainder() method.

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

  public static void main(String[] args) {
  
    double d1 = 102.20d , d2 = 32.29d;

    // returns the remainder
    double retval = StrictMath.IEEEremainder(d1, d2);
    System.out.println(" remainder = " + retval);

    /* if the first argument is finite and the second argument is infinite, 
    then the result is the same as the first argument */
    d1 = 30.12d;
    d2 = (1.0)/(0.0);
    retval = StrictMath.IEEEremainder(d1, d2);
    System.out.println(" remainder = " + retval);
  }
}

Let us compile and run the above program, this will produce the following result:

remainder = 5.330000000000005
remainder = 30.12



Advertisements
Advertisements