code: public static BigDecimal pow(BigDecimal x, BigDecimal y, MathContext mathContext) {
  		checkMathContext(mathContext);
  		if (x.signum() == 0) {
  			switch (y.signum()) {
  				case 0 : return round(ONE, mathContext);
  				case 1 : return round(ZERO, mathContext);
  			}
  		}
  
  		// TODO optimize y=0, y=1, y=10^k, y=-1, y=-10^k
  
  		try {
  			long longValue = y.longValueExact();
  			return pow(x, longValue, mathContext);
  		} catch (ArithmeticException ex) {
  			// ignored
  		}
  		
  		if (fractionalPart(y).signum() == 0) {
  			return powInteger(x, y, mathContext);
  		}
  
  		// x^y = exp(y*log(x))
  		MathContext mc = new MathContext(mathContext.getPrecision() + 6, mathContext.getRoundingMode());
  		BigDecimal result = exp(y.multiply(log(x, mc), mc), mc);
  
  		return round(result, mathContext);
  	}
docs: Calculates {@link BigDecimal} x to the power of {@link BigDecimal} y (x<sup>y</sup>).
  
  @param x the {@link BigDecimal} value to take to the power
  @param y the {@link BigDecimal} value to serve as exponent
  @param mathContext the {@link MathContext} used for the result
  @return the calculated x to the power of y with the precision specified in the <code>mathContext</code>
  @throws UnsupportedOperationException if the {@link MathContext} has unlimited precision
  @see #pow(BigDecimal, long, MathContext)