English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java Math mathematical methods
Java Math log10La méthode () calcule le logarithme en base d'une valeur spécifiée.10calculer le logarithme en base et le retourner ensuite.
log10La syntaxe de la méthode () est :
Math.log10(double x)
Attention: ce log10La méthode () est une méthode statique. Par conséquent, nous pouvons appeler cette méthode Math directement par le nom de la classe.
x - valeur dont on veut calculer le logarithme
retournela valeur de xde10logarithme en base
sixest NaN ou inférieur à zéro, alors retourne NaN
sixest l'infini positif, alors retourne l'infini positif
sixsi n est égal à zéro, alors retourne l'infini négatif
Attention:quand nlorsque n est un entier, la valeur est 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().