开发者

function to multiply very small or very big numbers

How can I multiply by a *10^(-20). I couldn't find any logarithmic functions so I hope开发者_JAVA技巧 there will be some others


Java doubles cover the range 4.9*10^-324 to 1.7*10^308, positive or negative. If your numbers fit within that range, and you are happy to use floating point precision, you can use the normal * operator.

The documentation for the Math.log method is here.


You can use BigDecimal class which can store large values for your calculations.


I wouldn't use a log function, I would use Math.pow

 double d = a * Math.pow(10, -20);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜