code: public static String string(double n) {
          if (Double.isInfinite(n)) {
              return (n > 0) ? "+inf" : "-inf";
          }
          return Double.toString(n);
      }
docs: Convert {@code double} to {@link String}. If {@code n} is infinite, returns positive/negative infinity {@code +inf} and
  {@code -inf}.
  
  @param n the double.
  @return string representation of {@code n}