Coerce to a double.

@param val
Object to be coerced.
@return The double coerced value.
@throws NullPointerException
if val is null and mode is strict.
978825
public double toDouble(Object val) {
    if (val == null) {
      return 0;
    }
    else if (val instanceof Double) {
      return ((Double) val).doubleValue();
    }
    else if (val instanceof Number) {
      // The below construct is used rather than ((Number)val).doubleValue() to ensure
      // equality between comparing new Double( 6.4 / 3 ) and the stencil expression of 6.4 / 3
      return Double.parseDouble(String.valueOf(val));
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue() ? 1. : 0.;
    }
    else if (val instanceof String) {
      String string = ((String) val).trim();
      if ("".equals(string)) {
        return Double.NaN;
      }
      else {
        // the spec seems to be iffy about this. Going to give it a wack anyway
        return Double.parseDouble(string);
      }
    }
    else if (val instanceof Character) {
      int i = ((Character) val).charValue();
      return i;
    }

    throw new ArithmeticException("Double coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
167770
@Override
    public double getDoubleValue( final String       key,
                                  final double       defaultValue )
    {
        return formatDoubleValue( key, getFormattedPropValue( key ), defaultValue );
    }
665992
public Item withDouble(String attrName, double val) {
        checkInvalidAttrName(attrName);
        return withNumber(attrName, Double.valueOf(val));
    }
180012
public static Double readDouble(String value, Double defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Double.valueOf(value);
	}
69191
protected int parseInt (String val)
    {
        try {
            return (val == null) ? -1 : Integer.parseInt(val);
        } catch (NumberFormatException nfe) {
            log.warning("Malformed integer value", "val", val);
            return -1;
        }
    }
1129807
private double parseIntoDouble(String value) {
        double returnVal = 0.0;
        if (value.charAt(0) == '.') value = "0" + value;
        int bracketIndex = value.indexOf('(');
        if (bracketIndex != -1) {
            value = value.substring(0, bracketIndex);
        }
        try {
            returnVal = Double.parseDouble(value);
        } catch (Exception exception) {
            logger.error("Could not parse double string: ", value);
        }
        return returnVal;
    }
88485
public double doubleValue(String name) {
        String s = childValue(name);
        if (s != null) {
            return Double.parseDouble(s);
        }
        throw new IllegalArgumentException(this + ": content: " + name);
    }
1350970
public double getDouble(String key, double defaultValue) {
    Object value = get(key);
    if (value instanceof Double) {
      return (double) value;
    }
    if (value instanceof Number) {
      return ((Number) value).doubleValue();
    } else if (value instanceof String) {
      try {
        return Double.valueOf((String) value);
      } catch (NumberFormatException ignored) {
      }
    }
    return defaultValue;
  }
434119
@CheckReturnValue
  @GwtIncompatible("Does not truncate correctly")
  public UnsignedInteger times(UnsignedInteger val) {
    // TODO(user): make this GWT-compatible
    return fromIntBits(value * checkNotNull(val).value);
  }
78860
@Override
  public void put(double val) {
    if(n <= 0) {
      n = 1;
      sum = val;
      m2 = 0;
      return;
    }
    final double tmp = n * val - sum;
    final double oldn = n; // tmp copy
    n += 1.0;
    sum += val;
    m2 += tmp * tmp / (n * oldn);
  }
379675
public Double convertToDouble(String value) {
        Double result = null;
        if (value != null) {
            result = Double.valueOf(value);
        }
        return result;
    }
886680
public String setValue(String val) {
        String oldVal = this.val;
        if (parent != null) {
            oldVal = parent.get(this.key); // trust the container more
            int i = parent.indexOfKey(this.key);
            if (i != Attributes.NotFound)
                parent.vals[i] = val;
        }
        this.val = val;
        return Attributes.checkNotNull(oldVal);
    }
938885
public JBBPOut Double(final double... value) throws IOException {
    assertNotEnded();
    assertArrayNotNull(value);
    if (this.processCommands) {
      for (final double d : value) {
        _writeDouble(d);
      }
    }
    return this;
  }
802778
public static double asDouble(Object value) {
        if (value instanceof Number) {
            return ((Number) value).doubleValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof CharSequence) {
            try {
                return Double.parseDouble(value.toString());
            } catch (NumberFormatException nfe) {
                throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
                                                     "\" to a double", nfe);
            }
        }
        throw new IncompatibleValueException(
                "Unable to convert " + value.getClass().getSimpleName() + " to a double");
    }
788839
protected static boolean isNull(Object val) {
    return (val == null) || STRING_NULL.equals(val) || DOUBLE_NULL.equals(val) || INTEGER_NULL.equals(val);
  }
539043
public double getValue()
    {
        Object objData = this.getData();
        if (objData != null)
        {
            Class<?> classData = this.getDataClass();
            if (classData != Object.class)
                if (classData == objData.getClass())
            {
                if (classData == Short.class)
                    return ((Short)objData).shortValue();
                else if (classData == Integer.class)
                    return ((Integer)objData).intValue();
                else if (classData == Float.class)
                    return ((Float)objData).floatValue();
                else if (classData == Double.class)
                    return ((Double)objData).doubleValue();
                else if (classData == java.util.Date.class)
                    return ((Date)objData).getTime();
                else if (classData == Boolean.class)
                    return (((Boolean)objData).booleanValue() ? 1 : 0);
                else if (classData != String.class)
                {
                    try   {
                        return this.stringToDouble((String)objData).doubleValue();
                    } catch (Exception ex)  { // Ignore the exception
                    }
                }
                }
        }
        return super.getValue();    // Return a 0
    }
1277914
@Override
    public void noteValue(double val) {
        super.noteValue(val);
        buf[insertPos++] = val;
        if (insertPos >= buf.length) {
            insertPos = 0;
            size = buf.length;
        } else if (insertPos > size) {
            size = insertPos;
        }
    }