* a_Rounding mode to round if necessary. For y > 8 it is better to use
     * power(BigDecimal,int,int,int,RoundingMode). For y &lt 2 this will return
     * a copy of x which is probably not what is wanted. This method should not
     * be used for such calculations. No check is made for efficiency reasons.
     */
    private static BigDecimal power(
            BigDecimal x,
            int y,
            int decimalPlaces,
            RoundingMode a_RoundingMode) {
        // x.pow(y) returned a mathematically incorrect result for
        // x = 1.0000000000000000000000000001, y1 = 100
        // Is x a "supernormal" number in this context?
        //BigDecimal result = x.pow(y1);// Don't attempt to support "supernormal" numbers.
        BigDecimal result = new BigDecimal(x.toString());
        int decimalPlacesMultiply;
        for (int i = 1; i < y; i++) {
            decimalPlacesMultiply = (result.scale() * x.scale()) + 1;
            decimalPlacesMultiply = Math.min(
                    decimalPlacesMultiply,
                    decimalPlaces + 2 + y);
            result = multiplyRoundIfNecessary(
                    result,
                    x,
                    decimalPlacesMultiply,
                    a_RoundingMode);
        }
        if (result.scale() > decimalPlaces) {
            roundIfNecessary(result, decimalPlaces, a_RoundingMode);
        }
        return result;
    }