@Test
  public void testPrecisionOverflow() {
    new Decimal128("1.004", (short) 3).checkPrecisionOverflow(4);

    try {
      new Decimal128("1.004", (short) 3).checkPrecisionOverflow(3);
      fail();
    } catch (ArithmeticException ex) {
    }

    try {
      new Decimal128("1.004", (short) 3).checkPrecisionOverflow(2);
      fail();
    } catch (ArithmeticException ex) {
    }

    new Decimal128("1.004", (short) 3).checkPrecisionOverflow(38);

    new Decimal128("-3322", (short) 0).checkPrecisionOverflow(4);
    try {
      new Decimal128("-3322", (short) 0).checkPrecisionOverflow(3);
      fail();
    } catch (ArithmeticException ex) {
    }

    new Decimal128("-3322", (short) 1).checkPrecisionOverflow(5);
    try {
      new Decimal128("-3322", (short) 1).checkPrecisionOverflow(4);
      fail();
    } catch (ArithmeticException ex) {
    }

    // Try the extremes of precision and scale.

    // digit  measuring stick:
    //                12345678901234567890123456789012345678
    new Decimal128("0.99999999999999999999999999999999999999", (short) 38)
      .checkPrecisionOverflow(38);

    try {
      new Decimal128("0.99999999999999999999999999999999999999", (short) 38)
        .checkPrecisionOverflow(37);
      fail();
    } catch (ArithmeticException ex) {
    }

    new Decimal128("99999999999999999999999999999999999999", (short) 0)
      .checkPrecisionOverflow(38);

    try {
      new Decimal128("99999999999999999999999999999999999999", (short) 0)
        .checkPrecisionOverflow(37);
      fail();
    } catch (ArithmeticException ex) {
    }
  }
During earlier code testing, if we found errors, test them here as regression tests.
common/src/test/org/apache/hadoop/hive/common/type/TestDecimal128.java