java.lang.Math.log10() 用於找出以 10 為底的數字的對數。此方法返回 double 值的以 10 為底的對數。
用法
public static double log10(double x)
參數
x= a value entered by user
返回
This method returns the base 10 logarithm of a.
- 如果參數為正值,則此方法將返回給定值的對數。
- 如果整數 n 的參數等於 10n,則此方法將返回 n。
- 如果參數為負值,則此方法將返回 NaN。
- 如果參數為 NaN,則此方法將返回 NaN。
- 如果參數是 Positive Infinity,則此方法將返回 Positive Infinity。
- 如果參數是正零或負零,此方法將返回負無窮大。
例子1
public class Log10Example1
{
public static void main(String[] args)
{
double x = 38.9;
// Input positive double, output logarithm of x
System.out.println(Math.log10(x));
}
}
輸出:
1.5899496013257077
例子2
public class Log10Example2
{
public static void main(String[] args)
{
double x = 100000;
// A power of 10 as input
System.out.println(Math.log10(x));
}
}
輸出:
5.0
例子3
public class Log10Example3
{
public static void main(String[] args)
{
double x = 1.0/0;
// Input positive infinity, output Infinity
System.out.println(Math.log10(x));
}
}
輸出:
Infinity
示例 4
public class Log10Example4
{
public static void main(String[] args)
{
double x = -45.8;
// Input negative double, output NaN
System.out.println(Math.log10(x));
}
}
輸出:
NaN
例 5
public class Log10Example5
{
public static void main(String[] args)
{
double x = 0;
// Input positive zero, output -Infinity
System.out.println(Math.log(x));
}
}
輸出:
-Infinity
相關用法
- Java Math.log1p()用法及代碼示例
- Java Math.log()用法及代碼示例
- Java Math.multiplyExact()用法及代碼示例
- Java Math.rint()用法及代碼示例
- Java Math.nextUp()用法及代碼示例
- Java Math.tan()用法及代碼示例
- Java Math.asin()用法及代碼示例
- Java Math.atan()用法及代碼示例
- Java Math.nextAfter()用法及代碼示例
- Java Math.exp()用法及代碼示例
- Java Math.tanh()用法及代碼示例
- Java Math.toDegrees()用法及代碼示例
- Java Math.getExponent()用法及代碼示例
- Java Math.toIntExact()用法及代碼示例
- Java Math.IEEEremainder()用法及代碼示例
- Java Math.sqrt()用法及代碼示例
- Java Math.incrementExact()用法及代碼示例
- Java Math.min()用法及代碼示例
- Java Math.signum()用法及代碼示例
- Java Math.copySign()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Math.log10() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。