java math log
数学类静态double log10(double d) (Math Class static double log10(double d) )
This method is available in java.lang package.
此方法在java.lang包中可用。
This method is used to return the logarithm of the given (base 10) of the given argument in the method.
此方法用于返回方法中给定参数的给定(以10为底)的对数。
This is a static method so it is accessible with the class name too.
这是一个静态方法,因此也可以使用类名进行访问。
The return type of this method is double, it returns the logarithm (base 10) of the given argument.
此方法的返回类型为double,它返回给定参数的对数(以10为底)。
In this method, we pass only one parameter as the double type whose logarithm (base 10) to be found.
在此方法中,我们仅传递一个参数作为double类型,其对数(以10为底)将被找到。
This method does not throw any exception.
此方法不会引发任何异常。
Syntax:
句法:
public static double log10(double d){
}
Parameter(s): It accepts a double value, whose logarithm (base 10) to be found.
参数:它接受一个双精度值,其对数(以10为底)将被找到。
Return value:
返回值:
The return type of this method is double, it returns the logarithm (base 10) of the given argument.
此方法的返回类型为double ,它返回给定参数的对数(以10为底)。
Note:
注意:
If we pass "NaN", it returns "NaN".
如果我们传递“ NaN”,则返回“ NaN”。
If we pass an argument which is equal to 10*n (n should be an integer type), it returns the n.
如果我们传递等于10 * n的参数( n应该是整数类型),它将返回n 。
If we pass a positive infinity, it returns the same (positive infinity).
如果我们传递一个正无穷大,它将返回相同的值(正无穷大)。
If we pass zero (-0 or 0), it returns the negative infinity.
如果我们传递零(-0或0),它将返回负无穷大。
Java程序演示log10(double d)方法的示例 (Java program to demonstrate example of log10(double d) method)
// Java program to demonstrate the example of
// log10(double d) method of Math Class
public class Log10Method {
public static void main(String[] args) {
// Here we are declaring few variables
double d1 = 7.0 / 0.0;
double d2 = -0.0;
double d3 = 6054.2;
// displaying values
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
// Here , we will get (Infinity) because we are
// passing parameter whose value is (-infinity)
System.out.println("Math.log10(d1): " + Math.log10(d1));
// Here , we will get (-Infinity) because we are
// passing parameter whose value is (-0.0)
System.out.println("Math.log10(d2): " + Math.log10(d2));
// Here , we will get (log [10 raised to the power of
// the given argument]) and we are passing parameter
// whose value is (6054.2)
System.out.println("Math.log10(d1): " + Math.log10(d3));
}
}
Output
输出量
E:\Programs>javac Log10Method.java
E:\Programs>java Log10Method
d1: Infinity
d2: -0.0
d3: 6054.2
Math.log10(d1): Infinity
Math.log10(d2): -Infinity
Math.log10(d1): 3.782056763740091
翻译自: https://www.includehelp.com/java/math-class-static-double-log10-double-d-with-example.aspx
java math log