BigDecimal to the power of BigDecimal on Java/Android

后端 未结 4 1732
终归单人心
终归单人心 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:20

    A utility class for BigDecimal https://github.com/tareknaj/BigFunctions

    Example for z = x^y --> z = exp ( ln(x) * y )

    final int SCALE = 10;
    BigDecimal x = new BigDecimal(1);
    BigDecimal y = new BigDecimal(12);
    
    BigDecimal z = BigFunctions.exp( BigFunctions.ln(x, SCALE).multiply(y),SCALE );
    

提交回复
热议问题