public static boolean fastUpdatePrecisionScale(
      final int fastSignum, long fast0, long fast1, long fast2,
      int fastIntegerDigitCount, int fastScale,
      int maxPrecision, int maxScale, FastCheckPrecisionScaleStatus status,
      FastHiveDecimal fastResult) {

    switch (status) {
    case UPDATE_SCALE_DOWN:
      {
        fastResult.fastSignum = fastSignum;

        // Throw away lower digits.
        if (!fastRoundFractionalHalfUp(
          fastSignum, fast0, fast1, fast2,
          fastScale - maxScale,
          fastResult)) {
          return false;
        }

        fastResult.fastScale = maxScale;

        // CONSIDER: For now, recompute integerDigitCount...
        fastResult.fastIntegerDigitCount =
            Math.max(0, fastRawPrecision(fastResult) - fastResult.fastScale);

        // And, round up may cause us to exceed our precision/scale...
        final int maxIntegerDigitCount = maxPrecision - maxScale;
        if (fastResult.fastIntegerDigitCount > maxIntegerDigitCount) {
          return false;
        }

        // Scaling down may have opened up trailing zeroes...
        final int trailingZeroCount =
            fastTrailingDecimalZeroCount(
                fastResult.fast0, fastResult.fast1, fastResult.fast2,
                fastResult.fastIntegerDigitCount, fastResult.fastScale);
        if (trailingZeroCount > 0) {
          // Scale down again.
          doFastScaleDown(
              fastResult,
              trailingZeroCount,
              fastResult);
          fastResult.fastScale -= trailingZeroCount;
        }
      }
      break;
    default:
      throw new RuntimeException("Unexpected fast check precision scale status " + status);
    }

    return true;
  }
Fast decimal scale up by factor of 10.
@param fast0 word 0 of the internal representation
@param fast1 word 1
@param fast2 word 2
@param scaleUp the number of integer digits to scale up by
@param fastResult an object to reuse
@return was the operation successfule?
storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java