List of utility methods to do BigDecimal Power
BigDecimal | pow(BigDecimal arg0, BigDecimal arg1) pow try { BigInteger bi = arg1.toBigIntegerExact(); return arg0.pow(bi.intValue(), MC_100); } catch (ArithmeticException ex) { int n = arg1.intValue(); switch (arg1.signum()) { case 0: if (arg0.compareTo(BigDecimal.ZERO) != 0) { ... |
BigDecimal | pow(BigDecimal b, int p, int q) Returns the result of bp/q as a BigDecimal .
BigDecimal result; int sign = p * q; if (b.signum() == 0) { if (sign > 0) { result = BigDecimal.ZERO; } else if (sign == 0) { result = BigDecimal.ONE; } else { ... |
BigDecimal | pow(BigDecimal base, BigDecimal exponent) pow BigDecimal result = BigDecimal.ZERO; int signOf2 = exponent.signum(); double dn1 = base.doubleValue(); BigDecimal n2 = exponent.multiply(new BigDecimal(signOf2)); BigDecimal remainderOf2 = n2.remainder(BigDecimal.ONE); BigDecimal n2IntPart = n2.subtract(remainderOf2); BigDecimal intPow = base.pow(n2IntPart.intValueExact()); BigDecimal doublePow = new BigDecimal(Math.pow(dn1, remainderOf2.doubleValue())); ... |
BigDecimal | pow(BigDecimal base, BigDecimal power) Raises the base to the power and returns the result. int precisionBase = base.precision(); int precisionPower = power.precision(); int precision = precisionBase < precisionPower ? precisionBase : precisionPower; MathContext context = new MathContext(precision, RoundingMode.HALF_DOWN); return pow(base, power, context); |
BigDecimal | pow(BigDecimal one, int another) pow return one.pow(another, _SCALE);
|
BigDecimal | pow(BigDecimal savedValue, BigDecimal value) pow BigDecimal result = null;
result = exp(ln(savedValue, 32).multiply(value), 32);
return result;
|
BigDecimal | power(BigDecimal base, int exponent) Returns the exponentiation of the given base raised to power of the given exponent. if (base == null) return null; return base.pow(exponent); |
BigDecimal | power(final BigDecimal value, final long power) This method returns the value multiplied by itself a number of times equal to the power. Internally, it uses bit-shifting and recursion to only perform if (power == 0) { return BigDecimal.ONE; BigDecimal lowerValue = power(value, power >>> 1); lowerValue = lowerValue.multiply(lowerValue); if ((power & 0x1l) == 0x1l) { return lowerValue.multiply(value); } else { ... |
BigDecimal | decimalPow(BigDecimal number, BigDecimal power) Pow for two decimals return new BigDecimal(Math.pow(number.doubleValue(), power.doubleValue())); |