public static boolean fastMultiply5x5HalfWords(
      long left0, long left1, long left2,
      long right0, long right1, long right2,
      FastHiveDecimal fastResult) {

    long product;

    final long halfRight0 = right0 % MULTIPLER_INTWORD_DECIMAL;
    final long halfRight1 = right0 / MULTIPLER_INTWORD_DECIMAL;
    final long halfRight2 = right1 % MULTIPLER_INTWORD_DECIMAL;
    final long halfRight3 = right1 / MULTIPLER_INTWORD_DECIMAL;
    final long halfRight4 = right2 % MULTIPLER_INTWORD_DECIMAL;

    final long halfLeft0 = left0 % MULTIPLER_INTWORD_DECIMAL;
    final long halfLeft1 = left0 / MULTIPLER_INTWORD_DECIMAL;
    final long halfLeft2 = left1 % MULTIPLER_INTWORD_DECIMAL;
    final long halfLeft3 = left1 / MULTIPLER_INTWORD_DECIMAL;
    final long halfLeft4 = left2 % MULTIPLER_INTWORD_DECIMAL;

    // v[0]
    product =
        halfRight0 * halfLeft0;
    final int z0 = (int) (product % MULTIPLER_INTWORD_DECIMAL);

    // v[1] where (product % MULTIPLER_INTWORD_DECIMAL) is the carry from v[0]. 
    product =
        halfRight0
      * halfLeft1
      + halfRight1
      * halfLeft0
      + (product / MULTIPLER_INTWORD_DECIMAL);
    final int z1 = (int) (product % MULTIPLER_INTWORD_DECIMAL);

    // v[2]
    product =
        halfRight0
      * halfLeft2
      + halfRight1
      * halfLeft1
      + halfRight2
      * halfLeft0
      + (product / MULTIPLER_INTWORD_DECIMAL);
    final int z2 = (int) (product % MULTIPLER_INTWORD_DECIMAL);

    // v[3]
    product =
        halfRight0
      * halfLeft3
      + halfRight1
      * halfLeft2
      + halfRight2
      * halfLeft1
      + halfRight3
      * halfLeft0
      + (product / MULTIPLER_INTWORD_DECIMAL);
    final int z3 = (int) (product % MULTIPLER_INTWORD_DECIMAL);

    // v[4]
    product =
        halfRight0
      * halfLeft4
      + halfRight1
      * halfLeft3
      + halfRight2
      * halfLeft2
      + halfRight3
      * halfLeft1
      + halfRight4
      * halfLeft0
      + (product / MULTIPLER_INTWORD_DECIMAL);

    // v[5] is not calculated since high integer is always 0 for our decimals.

    // These remaining combinations below definitely result in overflow.
    if ((halfRight4 != 0 && (halfLeft4 != 0 || halfLeft3 != 0 || halfLeft2 != 0 || halfLeft1 != 0))
        || (halfRight3 != 0 && (halfLeft4 != 0 || halfLeft3 != 0 || halfLeft2 != 0))
        || (halfRight2 != 0 && (halfLeft4 != 0 || halfLeft3 != 0))
        || (halfRight1 != 0 && halfLeft4 != 0)) {
      return false;
    }


    final long result0 = (long) z1 * MULTIPLER_INTWORD_DECIMAL + (long) z0;
    final long result1 = (long) z3 * MULTIPLER_INTWORD_DECIMAL + (long) z2;
    final long result2 = product;

    if (result0 == 0 && result1 == 0 && result2 == 0) {
      fastResult.fastSignum = 0;
    }
    fastResult.fast0 = result0;
    fastResult.fast1 = result1;
    fastResult.fast2 = result2;

    return true;
  }
Fast decimal multiplication on two decimals that have been already scaled and whose results
will fit in 38 digits.

The caller is responsible checking for overflow within the highword and determining
if scale down appropriate.

@return  Returns false if the multiplication resulted in large overflow.  Values in result are
         undefined in that case.
storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java