博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
strictmath_Java StrictMath log1p()方法与示例
阅读量:2529 次
发布时间:2019-05-11

本文共 3351 字,大约阅读时间需要 11 分钟。

strictmath

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

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

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

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

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

  • log1p() 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 also we will not get an error.

    log1p()方法是静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则也不会收到错误。

  • 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)。

  • log1p() method does not throw any exception.

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

Syntax:

句法:

public static double log1p(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 (1+d) of the given argument.

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

Note:

注意:

  • If we pass NaN, method returns NaN.

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

  • If we a value which is less than -1, method returns NaN.

    如果我们的值小于-1,则方法返回NaN。

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

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

  • If we pass a negative infinity, method returns NaN.

    如果我们传递一个负无穷大,则方法返回NaN。

  • If we pass 0 (negative or positive), method returns the same with the same sign.

    如果传递0(负数或正数),则方法将返回相同的符号。

Example:

例:

// Java program to demonstrate the example// of log1p(double d) method of StrictMath class.public class Log1p {
public static void main(String[] args) {
// variable declarations double d1 = 7.0 / 0.0; double d2 = -7.0 / 0.0; double d3 = 0.0; double d4 = -0.0; double d5 = 6054.2; // Display previous value of d1,d2,d3,d4 and d5 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("StrictMath.log1p(d1): " + StrictMath.log1p(d1)); // Here , we will get (NaN) because we are // passing parameter whose value is (-Infinity) System.out.println("StrictMath.log1p(d2): " + StrictMath.log1p(d2)); // Here , we will get (0.0) because we are // passing parameter whose value is (0.0) System.out.println("StrictMath.log1p(d3): " + StrictMath.log1p(d3)); // Here , we will get (-0.0) because we are // passing parameter whose value is (-0.0) System.out.println("StrictMath.log1p(d4): " + StrictMath.log1p(d4)); // Here , we will get (log [1 + d5]) and we are // passing parameter whose value is (6054.2) System.out.println("StrictMath.log1p(d5): " + StrictMath.log1p(d5)); }}

Output

输出量

d1: Infinityd2: -Infinityd3: 0.0d4: -0.0d5: 6054.2StrictMath.log1p(d1): InfinityStrictMath.log1p(d2): NaNStrictMath.log1p(d3): 0.0StrictMath.log1p(d4): -0.0StrictMath.log1p(d5): 8.708672685994957

翻译自:

strictmath

转载地址:http://bexzd.baihongyu.com/

你可能感兴趣的文章
[原创]一篇无关技术的小日记(仅作暂存)
查看>>
20145303刘俊谦 Exp7 网络欺诈技术防范
查看>>
原生和jQuery的ajax用法
查看>>
iOS开发播放文本
查看>>
20145202马超《java》实验5
查看>>
JQuery 事件
查看>>
main(argc,argv[])
查看>>
源码:Java集合源码之:哈希表(二)
查看>>
【HDU 3709】 Balanced Number (数位DP)
查看>>
JsonPath的使用
查看>>
企业常用的站内收索、QQ群、在线客服
查看>>
Centos下安装nginx步骤解析
查看>>
EntityFramework Code First 添加唯一键
查看>>
在线教育工具—白板系统的迭代1——bug监控排查
查看>>
招行ODC项目表彰
查看>>
js补充知识点-label应用
查看>>
给构造函数(constructor)创建对象(object)
查看>>
局域网访问PHP项目网站 用IP地址进入
查看>>
VM虚拟机,Linux系统安装tools过程遇到 what is the location of the “ifconfig” program
查看>>
Jquery实现循环删除Reaper某一行
查看>>