BigDecimal to the power of BigDecimal on Java/Android

后端 未结 4 1736
终归单人心
终归单人心 2020-12-07 01:43

I have a simple BigDecimal that I want to power to another BigDecimal, for example 11.11^-1.54. What would be the neatest way to do it in Java/Android? I don\'t like the ide

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 02:15

    Look into "Java Number Cruncher: The Java Programmer's Guide to Numerical Computing" - Chapter 12.5 Big Decimal Functions : there is some source code with as exact as possible algorithm to compute exponential and logarithm.

    Using the mathematical formula : x^y=exp(y*ln(x)) you can achieve a result with maximum precision.

    Nevertheless doubles do have a good precision and I strongly recommand you test if it's not precise enough for your need.

提交回复
热议问题