code: public void doSubstitution(double number, StringBuilder toInsertInto, int position, int recursionCount) {
          // perform a transformation on the number being formatted that
          // is dependent on the type of substitution this is
          //String s = toInsertInto.toString();
          double numberToFormat = transformNumber(number);
  
          if (withZeros && ruleSet != null) {
              // if there are leading zeros in the decimal expansion then emit them
              long nf = (long)numberToFormat;
              int len = toInsertInto.length();
              while ((nf *= 10) < denominator) {
                  toInsertInto.insert(position + pos, ' ');
                  ruleSet.format(0, toInsertInto, position + pos, recursionCount);
              }
              position += toInsertInto.length() - len;
          }
  
          // if the result is an integer, from here on out we work in integer
          // space (saving time and memory and preserving accuracy)
          if (numberToFormat == Math.floor(numberToFormat) && ruleSet != null) {
              ruleSet.format((long)numberToFormat, toInsertInto, position + pos, recursionCount);
  
              // if the result isn't an integer, then call either our rule set's
              // format() method or our DecimalFormat's format() method to
              // format the result
          } else {
              if (ruleSet != null) {
                  ruleSet.format(numberToFormat, toInsertInto, position + pos, recursionCount);
              } else {
                  toInsertInto.insert(position + pos, numberFormat.format(numberToFormat));
              }
          }
      }
docs: Performs a mathematical operation on the number, formats it using
  either ruleSet or decimalFormat, and inserts the result into
  toInsertInto.
  @param number The number being formatted.
  @param toInsertInto The string we insert the result into
  @param position The position in toInsertInto where the owning rule's
  rule text begins (this value is added to this substitution's
  position to determine exactly where to insert the new text)