这个 JAVA朗,数学。日志() 方法将双精度值的自然对数(基数e)作为参数返回。有多种情况:
null
- 如果论点是正确的 NaN或小于零 ,那么结果是 楠 .
- 如果论点是正确的 正无穷大 ,那么结果是 正无穷大 .
- 如果论点是正确的 正零还是负零 ,那么结果是 负无穷大 .
语法:
public static double log(double a)
参数:
a : User input
返回:
This method returns the value ln a.
例子: 表示工作 JAVA朗,数学。日志() 方法
// Java program to demonstrate working // of java.lang.Math.log() method import java.lang.Math; class Gfg { // driver code public static void main(String args[]) { double a = - 2.55 ; double b = 1.0 / 0 ; double c = 0 , d = 145.256 ; // negative integer as argument, output NAN System.out.println(Math.log(a)); // positive infinity as argument, output Infinity System.out.println(Math.log(b)); // positive zero as argument, output -Infinity System.out.println(Math.log(c)); // positive double as argument System.out.println(Math.log(d)); } } |
输出:
NaN Infinity -Infinity 4.978497702968366
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END