java math log
数学类静态double log1p(double d) (Math Class static double log1p(double d) )
This method is available in java.lang package.
此方法在java.lang包中可用。
This method is used to return (the logarithm of the sum of the given argument and 1 like log(1+d)) in the method.
此方法用于在方法中返回(给定参数和1之和的对数,如log(1 + d))。
This is a static method so it is accessible with the class name too.
这是一个静态方法,因此也可以使用类名进行访问。
We need to remember one thing if we pass smaller values for the given argument so the final calculated result of log1p(d) is nearer to the exact result of ln(1+d) than the double floating-point calculation of log(1.0+d)
如果为给定参数传递较小的值,则需要记住一件事,即与log(1.0+)的双浮点计算相比,log1p(d)的最终计算结果更接近ln(1 + d)的精确结果。 d)
The return type of this method is double, it returns the logarithm (1+d) of the given argument.
此方法的返回类型为double,它返回给定参数的对数(1 + d)。
In this method, we pass only one parameter as an argument of double type.
在此方法中,我们仅传递一个参数作为double类型的参数。
This method does not throw any exception.
此方法不会引发任何异常。
Syntax:
句法:
public static double log1p(double d){
}
Parameter(s): It accepts a double value, whose logarithm of the sum of the given argument and 1 like log(1+d)
参数:接受一个双精度值,该双精度值是给定参数和1的对数,如log(1 + d)
Return value:
返回值:
The return type of this method is double, it returns the logarithm (1+d) of the given argument.
此方法的返回类型为double ,它返回给定参数的对数(1 + d)。
Note:
注意:
If we pass "NaN", it returns "NaN".
如果我们传递“ NaN”,则返回“ NaN”。
If we pass value less than -1, it returns "NaN".
如果传递的值小于-1,则返回“ NaN”。
If we pass a positive infinity, it returns the same value (positive infinity).
如果我们传递一个正无穷大,它将返回相同的值(正无穷大)。
If we pass a negative infinity, it returns the "NaN".
如果我们传递一个负无穷大,它将返回“ NaN”。
If we pass zero (-0 or 0), it returns the same value.
如果我们传递零(-0或0),它将返回相同的值。
Java程序演示log1p(double d)方法的示例 (Java program to demonstrate example of log1p(double d) method)
// Java program to demonstrate the example of
// log1p(double d) method of Math Class.
public class Log1pMethod {
public static void main(String[] args) {
// Here we are declaring few variables
double d1 = 7.0 / 0.0;
double d2 = -7.0 / 0.0;
double d3 = 0.0;
double d4 = -0.0;
double d5 = 6054.2;
// displaying the values
System.out.println("d1 :" + d1);
System.out.println("d2 :" + d2);
System.out.println("d3 :" + d3);
System.out.println("d4 :" + d4);
System.out.println("d5 :" + d5);
// Here , we will get (Infinity) because we are passing
// parameter whose value is (Infinity)
System.out.println("Math.log1p(d1): " + Math.log1p(d1));
// Here , we will get (NaN) because we are passing
// parameter whose value is (-Infinity)
System.out.println("Math.log1p(d2): " + Math.log1p(d2));
// Here , we will get (0.0) because we are passing
// parameter whose value is (0.0)
System.out.println("Math.log1p(d3):" + Math.log1p(d3));
// Here , we will get (-0.0) because we are passing
// parameter whose value is (-0.0)
System.out.println("Math.log1p(d4):" + Math.log1p(d4));
// Here , we will get (log [1 + d5]) and we are
// passing parameter whose value is (6054.2)
System.out.println("Math.log1p(d5):" + Math.log1p(d5));
}
}
Output
输出量
E:\Programs>javac Log1pMethod.java
E:\Programs>java Log1pMethod
d1 :Infinity
d2 :-Infinity
d3 :0.0
d4 :-0.0
d5 :6054.2
Math.log1p(d1): Infinity
Math.log1p(d2): NaN
Math.log1p(d3):0.0
Math.log1p(d4):-0.0
Math.log1p(d5):8.708672685994957
翻译自: https://www.includehelp.com/java/math-class-static-double-log1p-double-d-with-example.aspx
java math log