* @param a_MathContext
     * @return x/y rounded to decimalPlaces decimal places if necessary using
     * a_RoundingMode RoundingMode
     */
    public static BigDecimal divideRoundIfNecessary(
            BigDecimal x,
            BigDecimal y,
            MathContext a_MathContext) {
        // Deal with special cases
        if (x.compareTo(BigDecimal.ZERO) == 0) {
            return BigDecimal.ZERO;
        }
        if (y.compareTo(BigDecimal.ZERO) == 0) {
            throw new ArithmeticException("Attempted division by zero...");
        }
        if (y.compareTo(BigDecimal.ONE) == 0) {
            return new BigDecimal(x.toString());
        }
        if (x.compareTo(y) == 0) {
            return BigDecimal.ONE;
        }
        return x.divide(y, a_MathContext);
    }