convert from dice roll structure to a single integer result
762223
def _sumDiceRolls(self, rollList):
        """"""
        if isinstance(rollList, RollList):
            self.rolls.append(rollList)
            return rollList.sum()
        else:
            return rollList
377102
def convert_to_int(value):
    
    if not value:
        return None

    # Apart from numbers also accept values that end with px
    if isinstance(value, str):
        value = value.strip(' px')

    try:
        return int(value)
    except (TypeError, ValueError):
        return None
528827
def random_int(maximum_value):
	
	if maximum_value == 0:
		return 0
	elif maximum_value == 1:
		return random_bits(1)

	bits = math.floor(math.log2(maximum_value))
	result = random_bits(bits) + random_int(maximum_value - ((2 ** bits) - 1))
	return result
601453
def to_int(self):
        
        coord = [int(round(x)) for x in self.xy_coord()]
        return self.from_xy(coord[0], coord[1], coord[2], coord[3])
263690
def to_int(d, key, default_to_zero=False, default=None, required=True):
    
    value = d.get(key) or default
    if (value in ["", None]) and default_to_zero:
        return 0
    if value is None:
        if required:
            raise ParseError("Unable to read %s from %s" % (key, d))
    else:
        return int(value)
62626
def add_die(self, die, count=1):
        '''
        '''
        for x in range(count):
            self._dice.append(die)
        self._odds = None
1083544
def roll_mean(input, window):
    ''''''
    nobs, i, j, sum_x = 0,0,0,0.
    N = len(input)

    if window > N:
        raise ValueError('Out of bound')

    output = np.ndarray(N-window+1,dtype=input.dtype)

    for val in input[:window]:
        if val == val:
            nobs += 1
            sum_x += val

    output[j] = NaN if not nobs else sum_x / nobs

    for val in input[window:]:
        prev = input[j]
        if prev == prev:
            sum_x -= prev
            nobs -= 1

        if val == val:
            nobs += 1
            sum_x += val

        j += 1
        output[j] = NaN if not nobs else sum_x / nobs

    return output
685614
def rollsd(self, scale=1, **kwargs):
        '''
        '''
        ts = self.rollapply('sd', **kwargs)
        if scale != 1:
            ts *= scale
        return ts
231150
public static int rollover(int value, int min, int max) {
		if (value < min) {
			int roll = (min - value) % (max - min + 1);
			return roll != 0 ? max + 1 - roll : min;
		} else if (value > max) {
			int roll = (value - max) % (max - min + 1);
			return roll != 0 ? min - 1 + roll : max;
		}
		return value;
	}
337793
def _int(ctx, number):
    
    return conversions.to_integer(conversions.to_decimal(number, ctx).to_integral_value(ROUND_FLOOR), ctx)
1068260
def gray2int(graystr):
    """"""
    num = bin2int(graystr)
    num ^= (num >> 8)
    num ^= (num >> 4)
    num ^= (num >> 2)
    num ^= (num >> 1)
    return num
414586
def to_uint(self):
        
        num = 0
        for i, f in enumerate(self._items):
            if f.is_zero():
                pass
            elif f.is_one():
                num += 1 << i
            else:
                fstr = "expected all functions to be a constant (0 or 1) form"
                raise ValueError(fstr)
        return num
374409
def numval(token):
    """"""
    if token.type == 'INTEGER':
        return int(token.value)
    elif token.type == 'FLOAT':
        return float(token.value)
    else:
        return token.value
567241
def to_int(self):
        
        num = self.to_uint()
        if num and self._items[-1].unbox():
            return num - (1 << self.size)
        else:
            return num
990773
def roll_group(group):
    
    group = regex.match(r'^(\d*)d(\d+)$', group, regex.IGNORECASE)
    num_of_dice = int(group[1]) if group[1] != '' else 1
    type_of_dice = int(group[2])
    assert num_of_dice > 0

    result = []
    for i in range(num_of_dice):
        result.append(random.randint(1, type_of_dice))
    return result
224257
private static Object toInt( BigDecimal value)
    {
    Object number;
        
    try
      {
      number =
        value.scale() == 0
        ? Integer.valueOf( value.intValueExact())
        : null;
      }
    catch( Exception e)
      {
      number = null;
      }
        
    return number;
    }
691431
def to_decimal(number, strip='- '):
    '''
    
    '''
    if isinstance(number, six.integer_types):
        return str(number)

    number = str(number)
    number = re.sub(r'[%s]' % re.escape(strip), '', number)

    # hexadecimal
    if number.startswith('0x'):
        return to_decimal(int(number[2:], 16))

    # octal
    elif number.startswith('o'):
        return to_decimal(int(number[1:], 8))

    # binary
    elif number.startswith('b'):
        return to_decimal(int(number[1:], 2))

    else:
        return str(int(number))