java.lang.StrictMath.IEEEremainder()%uA0方法计算两个参数的余数运算。
余数的算术值等于ꃱ - f2 %uD7 n,%uA0其中n是整数数学最接近商的确切数学值ꃱ/f2,%uA0而如果两个整数都同样接近f1/f2,则n是整数,它是偶数。
如果余数是零,它的符号与第一个参数的符号相同。它包括一些情况:
- 如果任一参数为NaN,或者第一个参数为无穷大,或者第二个参数是正零或负零,那么结果为NaN。
- 如果第一个参数是有限的,第二个参数为无穷大,那么结果是一样的第一个参数。
声明
以下是java.lang.StrictMath.IEEEremainder()方法的声明
public static double IEEEremainder(double f1, double f2)
参数
-
f1%uA0-- 这是被除数。
-
f2%uA0--这是除数。
返回值
此方法返回f1除以f2的余数。
异常
-
NA
例子
下面的例子显示java.lang.StrictMath.IEEEremainder()方法的使用。
package com.yiibai 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