这个 JAVA朗,数学。log10() 是Java中的一个内置方法,它接受双精度值作为参数,并返回 以10为底的对数 这个价值。从而计算给定参数的以10为底的对数值。
null
语法:
public static double log10(double val)
参数: 函数接受一个双精度值, 瓦尔 作为参数 基数10 计算对数。
返回值: 此函数返回 瓦尔 基于以下条件:
- 函数返回 楠 如果传递的参数为NaN或小于零
- 函数返回 正无穷大 如果争论通过了 正无穷大
- 函数返回 负无穷大 如果争论通过了 零 .
- 函数返回 A. 如果争论通过了
例如:
Input : 2018.0 Output : 7.609862200913554 Input : 1000000.0 Output : 6.0
下面的程序说明了 JAVA朗,数学。log10() :
项目1: 在这个程序中,有限的非零参数被作为参数传递。
// Java Program to illustrate // StrictMath.log10() function import java.io.*; import java.lang.*; class GFG { public static void main(String[] args) { double val1 = 2018.00567 , val2 = 100000.0 ; // Argument passed is infinite System.out.println( "Base 10 Logarithm of " + val1 + " is " + StrictMath.log10(val1)); // Passing zero as argument System.out.println( "Base 10 Logarithm of " + val2 + " is " + StrictMath.log10(val2)); } } |
输出:
Base 10 Logarithm of 2018.00567 is 3.3049223821418496 Base 10 Logarithm of 100000.0 is 5.0
项目2: 在这个程序中,无穷大和零作为参数传递。
// Java Program to illustrate // StrictMath.log10() function import java.io.*; import java.lang.*; class GFG { public static void main(String[] args) { double val = 2018 /( 0.0 ); System.out.println( "Base 10 Logarithm of " + val + " is " + StrictMath.log10(val)); System.out.println( "Base 10 Logarithm of 0 is " + StrictMath.log10( 0 )); } } |
输出:
Base 10 Logarithm of Infinity is Infinity Base 10 Logarithm of 0 is -Infinity
参考: https://docs.oracle.com/javase/8/docs/api/java/lang/StrictMath.html#log10()
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END