code: private char [] applyPrecision(int length) {
          char [] result = new char[nDigits];
          for (int i = 0; i < result.length; i++) result[i] = '0';
  
          if (length >= nDigits || length < 0) {
              // no rounding necessary
              System.arraycopy(digits, 0, result, 0, nDigits);
              return result;
          }
          if (length == 0) {
              // only one digit (0 or 1) is returned because the precision
              // excludes all significant digits
              if (digits[0] >= '5') {
                  result[0] = '1';
              }
              return result;
          }
  
          int i = length;
          int q = digits[i];
          if (q >= '5' && i > 0) {
              q = digits[--i];
              if ( q == '9' ) {
                  while ( q == '9' && i > 0 ){
                      q = digits[--i];
                  }
                  if ( q == '9' ){
                      // carryout! High-order 1, rest 0s, larger exp.
                      result[0] = '1';
                      return result;
                  }
              }
              result[i] = (char)(q + 1);
          }
          while (--i >= 0) {
              result[i] = digits[i];
          }
          return result;
      }
docs: rounds at a particular precision.