Converts the ``str`` argument to an integer:

	>>> from py_register_machine2.engine_tools.conversions import *
	>>> to_int("0x04")
	4
	>>> to_int("'a'")
	97
502083
def to_int(argument):
	
	if(argument.startswith("0b")):
		return int(argument[2:], 2)
	elif(argument.startswith("0x")):
		return int(argument[2:], 16)
	elif(argument.startswith("0") and argument != "0"):
		return int(argument[1:], 8)
	elif(argument[0] == "'" and argument[2] == "'"):
		return ord(argument[1])
	return int(argument)
930236
def convert_int(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, int):
        return value
    try:
        return int(value)
    except Exception as e:
        raise ValueError(str(e))
427646
def convert_string_to_number(str)
      matches = RE_NUMBER_STR.match(str)

      s = matches[:sign] == '-' ? -1 : 1
      i = matches[:integer].to_i
      f = matches[:fractional].to_i
      d = matches[:fractional] ? matches[:fractional].length : 0
      t = matches[:exponent_sign] == '-' ? -1 : 1
      e = matches[:exponent].to_i

      # I know this looks nutty, but it's exactly what's defined in the spec,
      # and it works.
      s * (i + f * 10**-d) * 10**(t * e)
    end
43450
def clean_int(x) -> int:
    
    try:
        return int(x)
    except ValueError:
        raise forms.ValidationError(
            "Cannot convert to integer: {}".format(repr(x)))
190656
def _fmt_int(cls, x, **kw):
        
        return str(int(round(cls._to_float(x))))
190822
def _len_int(obj):
    '''
    '''
    if obj:
        n, i = 1, abs(obj)
        if i > _digitmax:
             # no log(x[, base]) in Python 2.2
            n += int(log(i) * _digitlog)
    else:  # zero
        n = 0
    return n
842158
def _int_from_str(string):
    
    float_num = float(string)
    int_num = int(float_num)
    if float_num == int_num:
        return int_num
    else:
        # Needed to handle pseudos with fractional charge
        int_num = np.rint(float_num)
        logger.warning("Converting float %s to int %s" % (float_num, int_num))
        return int_num
698086
def pack_int(v):
    
    if v == 0:
        return "\0"
    ret = ''
    while v > 0:
        c = v & 127
        v >>= 7
        if v != 0:
            c = c | 128
        ret += chr(c)
    return ret
507476
def value_to_python(self, value):
        
        if not isinstance(value, bytes):
            raise tldap.exceptions.ValidationError("should be bytes")
        if value is None:
            return value
        try:
            return int(value)
        except (TypeError, ValueError):
            raise tldap.exceptions.ValidationError("is invalid integer")
1010716
public static Integer stringToInteger(String strString) throws Exception
    {
        Number objData;
        initGlobals();      // Make sure you have the utilities
        if ((strString == null) || (strString.equals(Constant.BLANK)))
            return null;
        strString = DataConverters.stripNonNumber(strString);
        try   {
            synchronized (gIntegerFormat)
            {
                objData = gIntegerFormat.parse(strString);
            }
            if (!(objData instanceof Integer))
            {
                if (objData instanceof Number)
                    objData = new Integer(objData.intValue());
                else
                    objData = null;
            }
        } catch (ParseException ex)   {
            objData = null;
        }
        if (objData == null)
            if (strString != null)
            if (strString.length() > 0)
        {
            try   {
                objData = new Integer(strString);
            } catch (NumberFormatException ex)  {
                throw ex;
            }
        }
        return (Integer)objData;
    }
337793
def _int(ctx, number):
    
    return conversions.to_integer(conversions.to_decimal(number, ctx).to_integral_value(ROUND_FLOOR), ctx)
898581
def integer(token):
        
        token = token.strip()
        neg = False
        if token.startswith(compat.b('-')):
            token = token[1:]
            neg = True
        if token.startswith(compat.b('0x')):
            result = int(token, 16)     # hexadecimal
        elif token.startswith(compat.b('0b')):
            result = int(token[2:], 2)  # binary
        elif token.startswith(compat.b('0o')):
            result = int(token, 8)      # octal
        else:
            try:
                result = int(token)     # decimal
            except ValueError:
                result = int(token, 16) # hexadecimal (no "0x" prefix)
        if neg:
            result = -result
        return result
560794
def int2str(num, radix=10, alphabet=BASE85):
    """"""
    return NumConv(radix, alphabet).int2str(num)
133922
def to_int(s):
    
    try:
        return int(s.replace('_', ''))
    except ValueError:
        return int(ast.literal_eval(s))
630924
def int_or_str(v: Optional[str]) -> Union[None, int, str]:
    """"""
    if v is None:
        return
    try:
        return int(v)
    except ValueError:
        return v
529762
def int_option(string, options):
    
    i = int(string)
    if i in options:
        return i

    raise ValueError('Not in allowed options')
628543
def integers(value):
    
    if '.' in value:
        raise ValueError('There are decimal points in %s' % value)
    values = value.replace(',', ' ').split()
    if not values:
        raise ValueError('Not a list of integers: %r' % value)
    try:
        ints = [int(float(v)) for v in values]
    except Exception:
        raise ValueError('Not a list of integers: %r' % value)
    return ints