English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java Math Mathematical Methods
Java Math log10o método calcula o logaritmo em base do valor especificado10logaritmo em base, e depois retorná-lo.
log10a sintaxe do método é:
Math.log10(double x)
Atenção: este log10o método é estático. Portanto, podemos chamar diretamente o método Math usando o nome da classe.
x - para calcular o valor logarítmico
retornabase xcom10logaritmo em base
sexfor NaN ou menor que zero, retorna NaN
sexfor infinito positivo, retorna infinito positivo
sexse for zero, retorna menos infinito
Atenção:quando né um inteiro, o valor é log10(10n) = n
class Main { public static void main(String[] args) { //calculation of the log of a double precision value10) System.out.println(Math.log10(9.0)) // 0.9542425094393249 //calculation of the log of 010) System.out.println(Math.log10(0.0)) // -Infinity //calculation of the log of NaN10) double nanValue = Math.sqrt(-5.0); System.out.println(Math.log10(nanValue)) // NaN //calculation of the log of infinity10) double infinity = Double.POSITIVE_INFINITY; System.out.println(Math.log10(infinity)) // Infinity //calculation of the log of a negative number10) System.out.println(Math.log(-9.0)) // NaN //calculation10of3log of the power10) System.out.println(Math.log10(Math.pow(10, 3)) // 3.0 } }
In the above example, please note the following expression:
Math.log10(Math.pow(10, 3))
Here, Math.pow(10, 3) Return103. For more information, please visit Java Math.pow().