Convert roman numbering back to decimal.
329562
function fromRoman( str )
	 {
		 str = str.toUpperCase();
		 var l = romans.length, retVal = 0;
		 for ( var i = 0; i < l; ++i )
		 {
			 for ( var j = romans[i], k = j[1].length; str.substr( 0, k ) == j[1]; str = str.substr( k ) )
				 retVal += j[ 0 ];
		 }
		 return retVal;
	 }
302396
def counter_style(self, val, style):
        """"""
        if style == 'decimal-leading-zero':
            if val < 10:
                valstr = "0{}".format(val)
            else:
                valstr = str(val)
        elif style == 'lower-roman':
            valstr = _to_roman(val).lower()
        elif style == 'upper-roman':
            valstr = _to_roman(val)
        elif style == 'lower-latin' or style == 'lower-alpha':
            if 1 <= val <= 26:
                valstr = chr(val + 96)
            else:
                log(WARN, 'Counter out of range for latin (must be 1...26)')
                valstr = str(val)
        elif style == 'upper-latin' or style == 'upper-alpha':
            if 1 <= val <= 26:
                valstr = chr(val + 64)
            else:
                log(WARN, 'Counter out of range for latin (must be 1...26)')
                valstr = str(val)
        elif style == 'decimal':
            valstr = str(val)
        else:
            log(WARN, u"ERROR: Counter numbering not supported for"
                u" list type {}. Using decimal.".format(
                    style).encode('utf-8'))
            valstr = str(val)
        return valstr
110659
def romanNumeral(n):
    
    if 0 > n > 4000: raise ValueError('``n`` must lie between 1 and 3999: %d' % n)
    roman   = 'I IV  V  IX  X  XL   L  XC    C   CD    D   CM     M'.split()
    arabic  = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
    res = []
    while n>0:
        pos = bisect.bisect_right(arabic, n)-1
        fit = n//arabic[pos]
        res.append(roman[pos]*fit); n -= fit * arabic[pos]
    return "".join(res)
889074
def int2roman(val):
    
    s = ''
    pos10 = 1000
    for pos in range(3, -1, -1):
        digit = val // pos10
        s += roman[pos][digit]
        val %= pos10
        pos10 //= 10
    return s
1144806
def decimal(self, var, default=NOTSET, force=True):
        
        return self._get(var, default=default, cast=Decimal, force=force)
157743
def sub(value, arg):
    """"""
    try:
        nvalue, narg = handle_float_decimal_combinations(
            valid_numeric(value), valid_numeric(arg), '-')
        return nvalue - narg
    except (ValueError, TypeError):
        try:
            return value - arg
        except Exception:
            return ''
1327181
def convert(self, amount: Number, currency: str, to: str, reverse: bool=False) -> Number:
        """"""
        rate = self.get_rate_for(currency, to, reverse)
        if self.return_decimal:
            amount = Decimal(amount)
        return amount * rate
479565
def convert_unit(self, column, value):
        ""
        if column not in self.units:
            return value

        # Try to interpret the value as a unit
        value = self.ureg(value)
        if isinstance(value, numbers.Number):
            # It's just a bare number, assume it's the column unit
            return value

        column_unit = self.ureg(self.units[column])
        return value.to(column_unit).magnitude
1215585
def __convert_num(number):
        
        try:
            return float(number)
        except ValueError as e:
            logger_noaa_lpd.warn("convert_num: ValueError: {}".format(e))
            return number
262042
def lower_endian_to_number(l, base):
  """"""
  return sum([d * (base**i) for i, d in enumerate(l)])
114378
def _f90repr(self, value):
        """"""
        if isinstance(value, bool):
            return self._f90bool(value)
        elif isinstance(value, numbers.Integral):
            return self._f90int(value)
        elif isinstance(value, numbers.Real):
            return self._f90float(value)
        elif isinstance(value, numbers.Complex):
            return self._f90complex(value)
        elif isinstance(value, basestring):
            return self._f90str(value)
        elif value is None:
            return ''
        else:
            raise ValueError('Type {0} of {1} cannot be converted to a Fortran'
                             ' type.'.format(type(value), value))
269283
def convert_value(self, value):
        """"""
        if isinstance(value, str):
            value = value.replace(self.separator, '')
            if self.decimal_point not in value:
                return int(value)
            else:
                return float(value.replace(self.decimal_point, '.'))
        elif self.int_to_float:
            return float(value)
        else:
            return value
381167
def floats(s):
    """"""
    try:
        return float(s)
    except ValueError:
        s = re.sub(r'(\d)\s*\(\d+(\.\d+)?\)', r'\1', s)        # Remove bracketed numbers from end
        s = re.sub(r'(\d)\s*±\s*\d+(\.\d+)?', r'\1', s)        # Remove uncertainties from end
        s = s.rstrip('\'"+-=<>/,.:;!?)]}…∼~≈×*_≥≤')             # Remove trailing punctuation
        s = s.lstrip('\'"+=<>/([{∼~≈×*_≥≤£$€#§')                # Remove leading punctuation
        s = s.replace(',', '')                                 # Remove commas
        s = ''.join(s.split())                                  # Strip whitespace
        s = re.sub(r'(\d)\s*[×x]\s*10\^?(-?\d)', r'\1e\2', s)  # Convert scientific notation
        return float(s)
590091
def number(v):
    """"""
    if nodesetp(v):
        v = string(v)
    try:
        return float(v)
    except ValueError:
        return float('NaN')
180226
def _abs(ctx, number):
    
    return conversions.to_decimal(abs(conversions.to_decimal(number, ctx)), ctx)
1052295
def as_number(as_number_val):
    """"""
    as_number_str = py23_compat.text_type(as_number_val)
    if "." in as_number_str:
        big, little = as_number_str.split(".")
        return (int(big) << 16) + int(little)
    else:
        return int(as_number_str)
1228965
def convert_decimal(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, decimal.Decimal):
        return value
    try:
        return decimal.Decimal(value)
    except Exception as e:
        raise ValueError(str(e))