Java Math IEEEremainder()方法及其示例

这个 JAVA朗,数学。IEEEremainder() 方法对IEEE 754标准规定的两个参数计算余数运算。余数值在数学上等于f1–f2 x n,其中n是最接近商f1/f2的精确数学值的数学整数,如果两个数学整数与f1/f2相等,则n是偶数。 注:

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

语法 :

public static double IEEEremainder(double dividend, double divisor)
Parameter:
dividend : the dividend.
divisor : the divisor.
Return :
This method returns the remainder when dividend is divided by divisor.

例1 :表示工作 JAVA朗,数学。IEEEremainder() 方法

// Java program to demonstrate working
// of java.lang.Math.IEEEremainder() method
import java.lang.Math;
class Gfg {
// driver code
public static void main(String args[])
{
double did1 = 31.34 ;
double dis1 = 2.2 ;
System.out.println(Math.IEEEremainder(did1, dis1));
double did2 = - 21.0 ;
double dis2 = 7.0 ;
// Sign of did2 is negative, Output is negative zero
System.out.println(Math.IEEEremainder(did2, dis2));
double did3 = 1.0 / 0 ;
double dis3 = 0.0 ;
// First argument is infinity and Second argument is zero
// Output NaN
System.out.println(Math.IEEEremainder(did3, dis3));
double did4 = - 2.34 ;
double dis4 = 1.0 / 0 ;
// First argument finite and Second argument is infinity
// Output first argument
System.out.println(Math.IEEEremainder(did4, dis4));
}
}


输出:

0.5399999999999974
-0.0
NaN
-2.34
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享