how to use ln in Java

后端 未结 2 922
一生所求
一生所求 2021-02-20 07:47

I\'m trying to use this formula in JAVA : (-ln(1-L))/L
I\'m not sure how to use ln in java.

相关标签:
2条回答
  • 2021-02-20 08:24

    Math.log(d) returns the natural logarithm (base e) of a double value.

    So the java code will be,

    double result = (-Math.log(1-L))/L;
    

    (but note that it's better to have variable names in lower-case - i.e. l instead of L)

    0 讨论(0)
  • 2021-02-20 08:29

    I also had no idea, but since it's a common math function, I checked the Math class in the API.

    Here you go: the log method

    EDIT: Sorry for broken link, Markdown is fixed now. Also I realized right after I posted this answer that it sounds snarky, which was not my intent; re-wordings just make it seems snarky AND sarcastic, though. I just wanted to make the point that the API really is useful for methods that could be reasonably expected to come up a lot.

    0 讨论(0)
提交回复
热议问题