Java log10()及其示例

这个 JAVA朗,数学。log10() 是用于返回基数10的Java数学库方法之一 给定双值的对数值作为参数。有多种情况:

null
  • 如果论点是正确的 正双倍值 数学log10()方法将返回 给定值的对数 价值 .
  • 如果论点是正确的 NaN或小于零 数学log10()方法将返回 .
  • 如果论点是正确的 正无穷大 数学log10()方法将返回以下结果: 正无穷大 .
  • 如果论点是正确的 正零还是负零 数学log10()方法将返回以下结果: 消极的 无穷 .

    语法:

    public static double log10(double a)

    参数:

    a : User input

    返回:

    This method returns the base 10 logarithm of a.

    例子: 表示工作 JAVA朗,数学。log10() 方法

    // Java program to demonstrate working
    // of java.lang.Math.log10() method
    import java.lang.Math;
    class Gfg {
    // driver code
    public static void main(String args[])
    {
    double a = 1000 ;
    double b = 145.256 ;
    double c = - 6.04 ;
    double d = 1.0 / 0 ;
    double e = 0 ;
    // A power of 10 as input
    System.out.println(Math.log10(a));
    // positive double value as argument,
    // output double value
    System.out.println(Math.log10(b));
    // negative integer as argument,
    // output NAN
    System.out.println(Math.log10(c));
    // positive infinity as argument,
    // output Infinity
    System.out.println(Math.log10(d));
    // positive zero as argument,
    // output -Infinity
    System.out.println(Math.log10(e));
    }
    }

    
    

    输出:

    3.0
    2.1621340805671756
    NaN
    Infinity
    -Infinity
    

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享