目录

static double IEEEremainder(double f1, double f2)

描述 (Description)

java.lang.StrictMath.IEEEremainder()方法计算两个参数的余数运算。

余数值在数学上等于f1 - f2 × n ,其中n是最接近商f1/f2的精确数学值的数学整数,并且如果两个数学整数同等地接近f1/f2 ,则n是整数这是偶数。

如果余数为零,则其符号与第一个参数的符号相同。它包括一些情况 -

  • 如果任一参数为NaN,或者第一个参数为无穷大,或者第二个参数为正零或负零,则结果为NaN。
  • 如果第一个参数是有限的,第二个参数是无限的,那么结果与第一个参数相同。

声明 (Declaration)

以下是java.lang.StrictMath.IEEEremainder()方法的声明

public static double IEEEremainder(double f1, double f2)

参数 (Parameters)

  • f1 - 这是股息。

  • f2 - 这是除数。

返回值 (Return Value)

当f1除以f2时,此方法返回余数。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.StrictMath.IEEEremainder()方法的用法。

package com.iowiki;
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);
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

remainder = 5.330000000000005
remainder = 30.12
↑回到顶部↑
WIKI教程 @2018