Java StrictMath IEEEremainder()方法
Java.lang.StrictMath.IEEEremainder()是StrictMath类的一个内置方法,用于对IEEE 754标准规定的两个参数进行剩余运算。
当余数为零时,其符号与第一个参数的符号相同。当任一参数为NaN,或num1为无限大,或num2为正负零时,它返回NaN。当num1是有限的, num2是无限的,其结果与num1相同。语法
public static double IEEEremainder(double num1, double num2)
参数: 该方法接受两个参数。
num1: 这是一个双倍数类型,是红利。num2:这也是一个双数类型,是除数。返回值: 该方法返回num1除以num2后的余数。
例子
输入:
num1 = 100.61d
num2 = 5.32d
输出:-0.47000000000000597
以下程序说明了Java.lang.StrictMath.IEEEremainder()方法:
程序1
// Java program to illustrate the// Java.lang.StrictMath.IEEEremainder()import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 5651.51d, num2 = 61.79d; // It returns the remainder value double remain_val = StrictMath.IEEEremainder(num1, num2); System.out.println("Remainder value of "+num1+" & "+num2 +" = " + remain_val); }}输出
Remainder value of 5651.51 & 61.79 = 28.620000000000296
程序2
// Java program to illustrate the// Java.lang.StrictMath.IEEEremainder()import java.lang.*; public class Geeks { public static void main(String[] args) { /* Here num1 is finite and num2 is infinite so the result is the same as the num1 */ double num1 = 70.55d, num2 = (1.0) / (0.0); double remain_val = StrictMath.IEEEremainder(num1, num2); System.out.println("Remainder value of "+num1+" & "+num2 +" = " + remain_val); }}输出
Remainder value is = 70.55
