code: public static double toDouble(String x) throws NumberFormatException {
          if ("nan".equals(x)) {
              return Double.NaN;
          }
          if ("inf".equals(x)) {
              return Double.POSITIVE_INFINITY;
          }
          if ("-inf".equals(x)) {
              return Double.NEGATIVE_INFINITY;
          }
  
          return Double.parseDouble(x);
      }
docs: Parses the given string into a scalar value
  
  @param x is the string to parse
  @return the given string into a scalar value
  @throws NumberFormatException if the string does not contain a scalar value