strictmath_Java StrictMath log10()方法与示例

strictmath

StrictMath类log10()方法 (StrictMath Class log10() method)

  • log10() method is available in java.lang package.

    log10()方法在java.lang包中可用。

  • log10() method is used to return the logarithm of the given (base 10) of the given argument in the method.

    log10()方法用于返回方法中给定参数的给定(以10为底)的对数。

  • log10() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

    log10()方法是静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • log10() method does not throw any exception.

    log10()方法不会引发任何异常。

Syntax:

句法:

    public static double log10(double d);

Parameter(s):

参数:

  • double d – represents the double type argument.

    double d –表示double类型的参数。

Return value:

返回值:

The return type of this method is double – it returns the logarithm (base 10) of the given argument.

此方法的返回类型为double-返回给定参数的对数(以10为底)。

Note:

注意:

  • If we pass NaN, method returns NaN.

    如果传递NaN,则方法返回NaN。

  • If we pass a value which is equal to 10*N (Here, N is an integer value), method returns the N.

    如果我们传递的值等于10 * N (此处N是整数值),则方法返回N。

  • If we pass a positive infinity, method returns the same (i.e. positive infinity).

    如果我们传递一个正无穷大,则方法将返回相同的值(即正无穷大)。

  • If we pass 0 (negative or positive), method returns the negative infinity.

    如果传递0(负数或正数),则方法将返回负无穷大。

Example:

例:

// Java program to demonstrate the example of 
// log10(double d) method of StrictMath Class.

public class Log10 {
    public static void main(String[] args) {
        // variable declarations
        double d1 = 7.0 / 0.0;
        double d2 = -0.0;
        double d3 = 6054.2;

        // Display previous value of d1,d2,d3
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);

        // Here , we will get (Infinity) because we are
        // passing parameter whose value is (-infinity)
        System.out.println("StrictMath.log10(d1): " + StrictMath.log10(d1));

        // Here , we will get (-Infinity) because we are
        // passing parameter whose value is (-0.0)
        System.out.println("StrictMath.log10(d2): " + StrictMath.log10(d2));

        // Here , we will get (log [10 raised to the power of the given argument])
        // and we are passing parameter whose value is (6054.2)
        System.out.println("StrictMath.log10(d3): " + StrictMath.log10(d3));
    }
}

Output

输出量

d1: Infinity
d2: -0.0
d3: 6054.2
StrictMath.log10(d1): Infinity
StrictMath.log10(d2): -Infinity
StrictMath.log10(d3): 3.782056763740091


翻译自: https://www.includehelp.com/java/strictmath-log10-method-with-example.aspx

strictmath

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值