Convert the string ``s`` in base ``base`` to a BigFloat instance, rounding
    according to the current context.

    Raise ValueError if ``s`` doesn't represent a valid string in the given
    base.
339411
def set_str2(s, base, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        _set_from_whole_string,
        (s, base),
        context,
    )
1232554
def cast_float(x):
    
    try:
        x = float(x)
    except ValueError:
        try:
            x = x.strip()
        except AttributeError as e:
            logger_misc.warn("parse_str: AttributeError: String not number or word, {}, {}".format(x, e))
    return x
671141
def parse_size(value):
    
    if isinstance(value, (int, float)):
        return value
    elif not pattern_valid.fullmatch(value):
        raise ValueError(value)

    result = 0
    for m in pattern.finditer(value):
        v = m.groupdict()
        n = int(v['n'])
        unit = v['unit']
        if not unit:
            result += n
        elif unit in size_levels:
            result += n << size_levels[unit]
        else:
            raise ValueError(value)
    return result
1126392
def _float(self, string):
        
        string = self._denoise(string)
        exp_match = re.match(r'^[-.\d]+x10-(\d)$', string)
        if exp_match:
            exp = int(exp_match.groups()[0])
            fac = 10 ** -exp
            string = string.replace('x10-{}'.format(exp), '')
        else:
            fac = 1

        return fac * float(string)
874493
def ParseFloat(text):
  
  try:
    # Assume Python compatible syntax.
    return float(text)
  except ValueError:
    # Check alternative spellings.
    if _FLOAT_INFINITY.match(text):
      if text[0] == '-':
        return float('-inf')
      else:
        return float('inf')
    elif _FLOAT_NAN.match(text):
      return float('nan')
    else:
      # assume '1.0f' format
      try:
        return float(text.rstrip('f'))
      except ValueError:
        raise ValueError('Couldn\'t parse float: %s' % text)
464670
public static float parseFloat(String s, float f) {
		if (s == null) {
			return f;
		}
		try {
			return Float.parseFloat(s.trim());
		} catch (NumberFormatException e) {
			return f;
		}
	}
175634
def validate(self, value):
        
        if isinstance(value, (str, unicode, int, long)):
            value = float(value)
        value = super(Float, self).validate(value)
        if not isinstance(value, (float)):
            raise ValueError("Not an float: %r" % (value, ))
        return value
773417
def __to_float(val, digits):
    """"""
    try:
        return round(float(val), digits)
    except (ValueError, TypeError):
        return float(0)
24695
def base_to_int(s, base):
    
    
    digit = {}
    for i,c in enumerate(string.digits + string.ascii_uppercase):
        digit[c] = i
    multiplier = 1
    res = 0
    for c in s[::-1]:
        res += digit[c] * multiplier
        multiplier *= base
    return res
215841
def _implicit_convert(cls, arg):
        """"""

        # ints, long and floats mix freely with BigFloats, and are
        # converted exactly.
        if isinstance(arg, six.integer_types) or isinstance(arg, float):
            return cls.exact(arg)
        elif isinstance(arg, BigFloat):
            return arg
        else:
            raise TypeError("Unable to convert argument %s of type %s "
                            "to BigFloat" % (arg, type(arg)))
1362984
def convert_from(self, base):
        """"""
        if self.identifier == 'bmp':
            return base
        elif self.identifier == 'man':
            result = []
            prefix = 'BOOST_METAPARSE_STRING("'
            while True:
                bmp_at = base.find(prefix)
                if bmp_at == -1:
                    return ''.join(result) + base
                else:
                    result.append(
                        base[0:bmp_at] + '::boost::metaparse::string<'
                    )
                    new_base = ''
                    was_backslash = False
                    comma = ''
                    for i in xrange(bmp_at + len(prefix), len(base)):
                        if was_backslash:
                            result.append(
                                '{0}\'\\{1}\''.format(comma, base[i])
                            )
                            was_backslash = False
                            comma = ','
                        elif base[i] == '"':
                            new_base = base[i+2:]
                            break
                        elif base[i] == '\\':
                            was_backslash = True
                        else:
                            result.append('{0}\'{1}\''.format(comma, base[i]))
                            comma = ','
                    base = new_base
                    result.append('>')
761005
function baseToString(value) {
  // Exit early for strings to avoid a performance hit in some environments.
  if (typeof value === 'string') {
    return value
  }
  if (isSymbol(value)) {
    return symbolToString ? symbolToString.call(value) : ''
  }
  var result = value + ''
  return result == '0' && 1 / value == -INFINITY ? '-0' : result
}
1088760
def t_float(self, s):
        '
        self.rv.append(Token(type='FLOAT', attr=s))
787061
private static float  parseFloat(String val) throws SVGParseException
   {
      int  len = val.length();
      if (len == 0)
         throw new SVGParseException("Invalid float value (empty string)");
      return parseFloat(val, 0, len);
   }
676833
def decode(self, s):
        
        if isinstance(s, basestring) and '&' in s:
            for x in self.decodings:
                s = s.replace(x[0], x[1])
        return s
922078
protected Float convertFloat(String value, String unit, int unary)
			throws IllegalArgumentException {

		try {
            if (unit != null)
            {
    			// trim & lowercase
    			value = value.trim().toLowerCase();
    			// trim units from value
                if (value.endsWith(unit))
                    value = value.substring(0, value.length() - unit.length());
            }

			return Float.parseFloat(value) * unary;
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException(
					"Invalid number format " + value, e);
		} catch (NullPointerException e) {
			throw new IllegalArgumentException("Invalid null format");
		}
	}
495606
def translate_state(self, s):
        
        if not isinstance(s, basestring):
            return s
        s = s.capitalize().replace("_", " ")
        return t(_(s))