@Test
  public void testToLong() {
    Decimal128 d = new Decimal128("1.25", (short) 2);
    assertEquals(1, d.longValue());
    d.update("4294967295", (short) 0); // 2^32-1
    assertEquals(4294967295L, d.longValue());
    d.update("4294967296", (short) 0); // 2^32 -- needs 2 32 bit words
    assertEquals(4294967296L, d.longValue());
    d.update("-4294967295", (short) 0); // -(2^32-1)
    assertEquals(-4294967295L, d.longValue());
    d.update("-4294967296", (short) 0); // -(2^32)
    assertEquals(-4294967296L, d.longValue());
    d.update("4294967295.01", (short) 2); // 2^32-1 + .01
    assertEquals(4294967295L, d.longValue());
    d.update("4294967296.01", (short) 2); // 2^32 + .01
    assertEquals(4294967296L, d.longValue());

    // Compare long value with HiveDecimal#longValue
    d.update(37.678, (short)5);
    HiveDecimal hd = HiveDecimal.create(BigDecimal.valueOf(37.678));
    assertEquals(hd.longValue(), d.longValue());
  }
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