code: private int checkExponent(int length) {
          if (length >= nDigits || length < 0)
              return decExponent;
  
          for (int i = 0; i < length; i++)
              if (digits[i] != '9')
                  // a '9' anywhere in digits will absorb the round
                  return decExponent;
          return decExponent + (digits[length] >= '5' ? 1 : 0);
      }
docs: Given the desired number of digits predict the result's exponent.