@Test
  public void testDivision() {
    {
      int[] dividend = new int[] { 1 + 33, 2 + 21, 3, 4 + 10, 20, 30, 40, 0 };
      int[] divisor = new int[] { 1, 2, 3, 4 };
      int[] quotient = new int[5];
      int[] remainder = SqlMathUtil.divideMultiPrecision(dividend, divisor,
          quotient);
      assertArrayEquals(new int[] { 1, 0, 0, 10, 0 }, quotient);
      assertArrayEquals(new int[] { 33, 21, 0, 0, 0, 0, 0, 0, 0 }, remainder);
    }

    {
      int[] dividend = new int[] { 0xF7000000, 0, 0x39000000, 0 };
      int[] divisor = new int[] { 0xF700, 0, 0x3900, 0 };
      int[] quotient = new int[5];
      int[] remainder = SqlMathUtil.divideMultiPrecision(dividend, divisor,
          quotient);
      assertArrayEquals(new int[] { 0x10000, 0, 0, 0, 0 }, quotient);
      assertArrayEquals(new int[] { 0, 0, 0, 0, 0 }, remainder);
    }

    {
      // Zero dividend
      int[] dividend = new int[] { 0, 0, 0, 0 };
      int[] divisor = new int[] { 0xF700, 0, 0x3900, 0 };
      int[] quotient = new int[5];
      int[] remainder = SqlMathUtil.divideMultiPrecision(dividend, divisor,
          quotient);
      assertArrayEquals(new int[] { 0, 0, 0, 0, 0 }, quotient);
      assertArrayEquals(new int[] { 0, 0, 0, 0, 0 }, remainder);
    }
  }
This code was based on code from Microsoft's PolyBase.
common/src/test/org/apache/hadoop/hive/common/type/TestSqlMathUtil.java