code: public String form( double x ) {
          String r;
  
          if (precision < 0) {
              precision = 6;
          }
  
          int s = 1;
  
          if (x < 0) {
              x = -x;
              s = -1;
          }
          if (fmt == 'f') {
              r = fixedFormat(x);
          } else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G') {
              r = expFormat(x);
          } else {
              throw new java.lang.IllegalArgumentException();
          }
  
          return pad(sign(s, r));
      }
docs: Formats a double into a string (like sprintf in C)
  
  @param x      the number to format
  
  @return the formatted string