strictmath
StrictMath類log10()方法 (StrictMath Class log10() method)
log10() method is available in java.lang package.
log10()方法在java.lang包中可用。
log10() method is used to return the logarithm of the given (base 10) of the given argument in the method.
log10()方法用于返回方法中給定參數的給定(以10為底)的對數。
log10() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
log10()方法是靜態方法,因此可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,則不會出現任何錯誤。
log10() method does not throw any exception.
log10()方法不會引發任何異常。
Syntax:
句法:
public static double log10(double d);
Parameter(s):
參數:
double d – represents the double type argument.
double d –表示double類型的參數。
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, method returns NaN.
如果傳遞NaN,則方法返回NaN。
If we pass a value which is equal to 10*N (Here, N is an integer value), method returns the N.
如果我們傳遞的值等于10 * N (此處N是整數值),則方法返回N。
If we pass a positive infinity, method returns the same (i.e. positive infinity).
如果我們傳遞一個正無窮大,則方法將返回相同的值(即正無窮大)。
If we pass 0 (negative or positive), method returns the negative infinity.
如果傳遞0(負數或正數),則方法將返回負無窮大。
Example:
例:
// Java program to demonstrate the example of
// log10(double d) method of StrictMath Class.
public class Log10 {
public static void main(String[] args) {
// variable declarations
double d1 = 7.0 / 0.0;
double d2 = -0.0;
double d3 = 6054.2;
// Display previous value of d1,d2,d3
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("StrictMath.log10(d1): " + StrictMath.log10(d1));
// Here , we will get (-Infinity) because we are
// passing parameter whose value is (-0.0)
System.out.println("StrictMath.log10(d2): " + StrictMath.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("StrictMath.log10(d3): " + StrictMath.log10(d3));
}
}
Output
輸出量
d1: Infinity
d2: -0.0
d3: 6054.2
StrictMath.log10(d1): Infinity
StrictMath.log10(d2): -Infinity
StrictMath.log10(d3): 3.782056763740091
翻譯自: https://www.includehelp.com/java/strictmath-log10-method-with-example.aspx
strictmath