public static BigInteger fastBigIntegerValueScaled(
      int fastSignum, long fast0, long fast1, long fast2,
      int fastIntegerDigitCount, int fastScale,
      int fastSerializationScale) {

    // Use the serialization scale and create a BigInteger with trailing zeroes (or
    // round the decimal) if necessary.
    //
    // Since we are emulating old behavior and recommending the use of HiveDecimal.bigIntegerBytesScaled
    // instead just do it the slow way.  Get the BigDecimal.setScale value and return the
    // BigInteger.
    //
    BigDecimal bigDecimal =
        fastBigDecimalValue(
            fastSignum, fast0, fast1, fast2,
            fastIntegerDigitCount, fastScale);
    bigDecimal = bigDecimal.setScale(fastSerializationScale, RoundingMode.HALF_UP);
    return bigDecimal.unscaledValue();
  }
*********************************************************************************************
  // Decimal to Non-Integer conversion.

  public static float fastFloatValue(
      int fastSignum, long fast0, long fast1, long fast2,
      int fastIntegerDigitCount, int fastScale) {
    if (fastSignum == 0) {
      return 0;
    }
    BigDecimal bigDecimal = fastBigDecimalValue(
        fastSignum, fast0, fast1, fast2,
        fastIntegerDigitCount, fastScale);
    return bigDecimal.floatValue();
  }

  public static double fastDoubleValue(
      int fastSignum, long fast0, long fast1, long fast2,
      int fastIntegerDigitCount, int fastScale) {
    if (fastSignum == 0) {
      return 0;
    }

    // CONSIDER: Looked at the possibility of faster decimal to double conversion by using some
    //           of their lower level logic that extracts the various parts out of a double.
    //           The difficulty is Java's rounding rules are byzantine.

    BigDecimal bigDecimal = fastBigDecimalValue(
        fastSignum, fast0, fast1, fast2,
        fastIntegerDigitCount, fastScale);
    return bigDecimal.doubleValue();
  }

  /**
Get a BigInteger representing the decimal's digits without a dot.

@param fastSignum the sign (-1, 0, or +1)
@param fast0 word 0 of the internal representation
@param fast1 word 1
@param fast2 word 2
@param fastIntegerDigitCount the number of integer digits
@param fastScale the scale of the number
@param fastSerializationScale the scale to serialize
@return Returns a signed BigInteger.
storage-api/src/java/org/apache/hadoop/hive/common/type/FastHiveDecimalImpl.java