public static boolean fastAdd(
      int leftSignum, long leftFast0, long leftFast1, long leftFast2,
      int leftIntegerDigitCount, int leftScale,
      int rightSignum, long rightFast0, long rightFast1, long rightFast2,
      int rightIntegerDigitCount, int rightScale,
      FastHiveDecimal fastResult) {

    if (rightSignum == 0) {
      fastResult.fastSet(leftSignum, leftFast0, leftFast1, leftFast2, leftIntegerDigitCount, leftScale);
      return true;
    }
    if (leftSignum == 0) {
      fastResult.fastSet(rightSignum, rightFast0, rightFast1, rightFast2, rightIntegerDigitCount, rightScale);
      return true;
    }

    if (leftScale == rightScale) {
      return doAddSameScale(
          leftSignum, leftFast0, leftFast1, leftFast2,
          rightSignum, rightFast0, rightFast1, rightFast2,
          leftScale,
          fastResult);
    } else {
      return doAddDifferentScale(
          leftSignum, leftFast0, leftFast1, leftFast2,
          leftIntegerDigitCount, leftScale,
          rightSignum, rightFast0, rightFast1, rightFast2,
          rightIntegerDigitCount, rightScale,
          fastResult);
    }
  }
Add the two decimals.

NOTE: Scale Determination for Addition/Subtraction

One could take the Math.min of the scales and adjust the operand with the lower scale have a
scale = higher scale.

But this does not seem to work with decimals with widely varying scales as these:

    598575157855521918987423259.94094                            dec1 (int digits 27,scale 5)
 +                            0.0000000000006711991169422033     dec2 (int digits 0, scale 28)

Trying to make dec1 to have a scale of 28 (i.e. by adding trailing zeroes) would exceed
MAX_PRECISION (int digits 27 + 28 &gt; 38).

In this example we need to make sure we have enough integer digit room in the result to
handle dec1's digits.  In order to maintain that, we will need to get rid of lower
fractional digits of dec2.  But when do we do that?

OldHiveDecimal.add does the full arithmetic add with all the digits using BigDecimal and
then adjusts the result to fit in MAX_PRECISION, etc.

If we try to do pre-rounding dec2 it is problematic.  We'd need to know if there is a carry in
the arithmetic in order to know at which scale to do the rounding.  This gets complicated.

So, the simplest thing is to emulate what OldHiveDecimal does and do the full digit addition
and then fit the result afterwards.

@param leftSignum The left sign (-1, 0, or +1)
@param leftFast0 The left word 0 of reprentation
@param leftFast1 word 1
@param leftFast2 word 2
@param leftIntegerDigitCount The left number of integer digits
@param leftScale the left scale
@param rightSignum The right sign (-1, 0, or +1)
@param rightFast0 The right word 0 of reprentation
@param rightFast1 word 1
@param rightFast2 word 2
@param rightIntegerDigitCount The right number of integer digits
@param rightScale the right scale
@param fastResult an object to reuse
@return True if the addition was successful; Otherwise, false is returned on overflow.
storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java