Parse a float from a String in a safe manner.

@param val           the string to parse
@param defVal        the default value to return if parsing fails
@return              the parsed float, or default value
491524
public static float parseFloat(String val, float defVal){
        if(TextUtils.isEmpty(val)) return defVal;
        try{
            return Float.parseFloat(val);
        }catch (NumberFormatException e){
            return defVal;
        }
    }
1335175
def _parse_parameters(val_type, val):
    
    if val_type == "logical":
        return val == "T"
    elif val_type == "int":
        return int(val)
    elif val_type == "string":
        return val.strip()
    else:
        return float(val)
1075621
protected boolean isFloatingPointNumber(Object val) {
    if (val instanceof Float || val instanceof Double) {
      return true;
    }
    if (val instanceof String) {
      String string = (String) val;
      return string.indexOf('.') != -1 || string.indexOf('e') != -1 || string.indexOf('E') != -1;
    }
    return false;
  }
1049790
def parse_float(float_str):
    """"""
    factor = __get_factor(float_str)
    if factor != 1:
        float_str = float_str[:-1]

    try:
        return float(float_str.replace(',', '')) * factor
    except ValueError:
        return None
294921
public float getFloat(String pName, float defaultValue) {
        String pValue = _properties.getProperty(pName);
        return parseFloat(pName, pValue, defaultValue);
    }
651314
function parseValue(value) {
    if (['true', 'false'].includes(value)) {
        return value === 'true';
    }
    // is it float parsable?
    const parsed = parseFloat(value);
    if (!isNaN(parsed)) {
        return parsed;
    }
    return value;
}
400341
def str_val(val):
    
    str_val = val
    if val is None:
        str_val = "NA"
    elif type(val) == float:
        str_val = '%0.2f' % val
    else:
        str_val = str(val)
    return str_val
839609
function parse(val) {
  if (typeof val === 'number' && !isNaN(val)) {
    return val;
  }

  if (typeof val !== 'string') {
    return null;
  }

  // Test if the string passed is valid
  var results = parseRegExp.exec(val);
  var floatValue;
  var unit = 'b';

  if (!results) {
    // Nothing could be extracted from the given string
    floatValue = parseInt(val, 10);
    unit = 'b'
  } else {
    // Retrieve the value and the unit
    floatValue = parseFloat(results[1]);
    unit = results[4].toLowerCase();
  }

  return Math.floor(map[unit] * floatValue);
}
1220039
function (val) {
		var parseDate = this.options.parseDate,
			ret,
			key,
			format,
			match;

		if (parseDate) {
			ret = parseDate(val);
		}
			
		if (typeof val === 'string') {
			for (key in this.dateFormats) {
				format = this.dateFormats[key];
				match = val.match(format.regex);
				if (match) {
					ret = format.parser(match);
				}
			}
		}
		return ret;
	}
1098744
public Item withFloat(String attrName, float val) {
        checkInvalidAttrName(attrName);
        return withNumber(attrName, Float.valueOf(val));
    }
710793
public float getFloat(String key, float defaultValue) {
    if (containsKey(key)) {
      return Float.parseFloat(get(key));
    } else {
      return defaultValue;
    }
  }
784764
function toInteger(val, def) {
    if (!is_1.isValue(val))
        return toDefault(null, def);
    var parsed = function_1.tryWrap(parseInt, val)(def);
    if (is_1.isInteger(parsed))
        return parsed;
    if (toBoolean(val))
        return 1;
    return 0;
}
1140891
public static String getOr (String value, String defval)
    {
        return isBlank(value) ? defval : value;
    }
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;
    }
541799
def convert_float(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, float):
        return value
    try:
        return float(value)
    except Exception as e:
        raise ValueError(str(e))
213395
def parse(self, val):
        
        s = str(val).lower()
        if s == "true":
            return True
        elif s == "false":
            return False
        else:
            raise ValueError("cannot interpret '{}' as boolean".format(val))
698869
private static Float  parseOpacity(String val)
   {
      try {
         float  o = parseFloat(val);
         return (o < 0f) ? 0f : (o > 1f) ? 1f : o;
      } catch (SVGParseException e) {
         return null;
      }
   }