java math log_Java Math类静态double log1p(double d)及其示例

news/2024/5/19 6:03:40 标签: java, python, jvm, jdk, 反射

java math log

数学类静态double log1p(double d) (Math Class static double log1p(double d) )

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return (the logarithm of the sum of the given argument and 1 like log(1+d)) in the method.

    此方法用于在方法中返回(给定参数和1之和的对数,如log(1 + d))。

  • This is a static method so it is accessible with the class name too.

    这是一个静态方法,因此也可以使用类名进行访问。

  • We need to remember one thing if we pass smaller values for the given argument so the final calculated result of log1p(d) is nearer to the exact result of ln(1+d) than the double floating-point calculation of log(1.0+d)

    如果为给定参数传递较小的值,则需要记住一件事,即与log(1.0+)的双浮点计算相比,log1p(d)的最终计算结果更接近ln(1 + d)的精确结果。 d)

  • The return type of this method is double, it returns the logarithm (1+d) of the given argument.

    此方法的返回类型为double,它返回给定参数的对数(1 + d)。

  • In this method, we pass only one parameter as an argument of double type.

    在此方法中,我们仅传递一个参数作为double类型的参数。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    public static double log1p(double d){
    }

Parameter(s): It accepts a double value, whose logarithm of the sum of the given argument and 1 like log(1+d)

参数:接受一个双精度值,该双精度值是给定参数和1的对数,如log(1 + d)

Return value:

返回值:

The return type of this method is double, it returns the logarithm (1+d) of the given argument.

此方法的返回类型为double ,它返回给定参数的对数(1 + d)。

Note:

注意:

  • If we pass "NaN", it returns "NaN".

    如果我们传递“ NaN”,则返回“ NaN”。

  • If we pass value less than -1, it returns "NaN".

    如果传递的值小于-1,则返回“ NaN”。

  • If we pass a positive infinity, it returns the same value (positive infinity).

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

  • If we pass a negative infinity, it returns the "NaN".

    如果我们传递一个负无穷大,它将返回“ NaN”。

  • If we pass zero (-0 or 0), it returns the same value.

    如果我们传递零(-0或0),它将返回相同的值。

Java程序演示log1p(double d)方法的示例 (Java program to demonstrate example of log1p(double d) method)

// Java program to demonstrate the example of 
// log1p(double d) method of Math Class.

public class Log1pMethod {
    public static void main(String[] args) {
        // Here we are declaring few variables
        double d1 = 7.0 / 0.0;
        double d2 = -7.0 / 0.0;
        double d3 = 0.0;
        double d4 = -0.0;
        double d5 = 6054.2;

        // displaying the values
        System.out.println("d1 :" + d1);
        System.out.println("d2 :" + d2);
        System.out.println("d3 :" + d3);
        System.out.println("d4 :" + d4);
        System.out.println("d5 :" + d5);

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

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

        // Here , we will get (0.0) because we are passing 
        // parameter whose value is (0.0)
        System.out.println("Math.log1p(d3):" + Math.log1p(d3));

        // Here , we will get (-0.0) because we are passing 
        // parameter whose value is (-0.0)
        System.out.println("Math.log1p(d4):" + Math.log1p(d4));

        // Here , we will get (log [1 + d5]) and we are 
        // passing parameter whose value is (6054.2)
        System.out.println("Math.log1p(d5):" + Math.log1p(d5));
    }
}

Output

输出量

E:\Programs>javac Log1pMethod.java

E:\Programs>java Log1pMethod
d1 :Infinity
d2 :-Infinity
d3 :0.0
d4 :-0.0
d5 :6054.2
Math.log1p(d1): Infinity
Math.log1p(d2): NaN
Math.log1p(d3):0.0
Math.log1p(d4):-0.0
Math.log1p(d5):8.708672685994957


翻译自: https://www.includehelp.com/java/math-class-static-double-log1p-double-d-with-example.aspx

java math log


http://www.niftyadmin.cn/n/1255944.html

相关文章

【转】Python3学习笔记(urllib模块的使用)

原文地址:https://www.cnblogs.com/Lands-ljk/p/5447127.html 1.基本方法 urllib.request.urlopen(url, dataNone, [timeout, ]*, cafileNone, capathNone, cadefaultFalse, contextNone) - url: 需要打开的网址 - data:Post提交的数据…

python 打印文件名_Python | 打印文件内容以及文件名

python 打印文件名打印文件名 (Printing file name ) To print the filename, we use "file_object.name". 要打印文件名,我们使用“ file_object.name” 。 打印文件内容 (Printing files content) To print the content of a file, we use "read(…

ici isi_ISI的完整形式是什么?

ici isiISI:印度标准协会/服务间情报/印度统计研究所 (ISI: Indian Standards Institute / Inter-Service Intelligence / Indian Statistical Institute) 1)ISI:印度标准协会 (1) ISI: Indian Standards Institute) ISI is an abbreviation of the Indi…

Which前加逗号与不加逗号有什么区别

Which 引导非限制性定语从句时,前面要加逗号,引导限制性定语从句时就不能加逗号。 Which的用法: 关系代词which的用法 在非限定性定语从句中,只宜用which, 不宜用that. Beijing, which is the capital of China, is a very beautiful cit…

分而治之_分而治之范式(它是什么,其应用,优缺点)

分而治之In the branch of Computer Science and Engineering, Information Technology and all the associated branches among these fields the term "Divide and Conquer" is an algorithm design paradigm based on the principle of recursion ( multi-branche…

Modbus 协议解析

转载于:https://www.cnblogs.com/pertor/p/8746897.html

mcq 队列_MCQ | 8086微处理器中的过程和宏

mcq 队列Question 1: 问题1: Which of the following assembler directives are used to define a Procedure in the 8086 microprocessor? 以下哪个汇编程序伪指令用于在8086微处理器中定义过程? PROCEDURE and ENDP 程序和结束 STARTP and ENDP ST…

Powers of i in Complex Numbers

1、https://math.stackexchange.com/questions/3168114/powers-of-i-in-complex-numbers?noredirect12、https://math.libretexts.org/Bookshelves/Precalculus/Book%3A_Trigonometry_(Sundstrom_and_Schlicker)/05%3A_Complex_Numbers_and_Polar_Coordinates/5.03%3A_DeMoivr…