def multi_adder(a_bit_int, b_bit_int, c=0): check_bit_int_size(a_bit_int, b_bit_int) check_is_binary(c) answer = a_bit_int + b_bit_int if answer > MAX_BIT_INT: answer = MIN_BIT_INT + (answer - MAX_BIT_INT - 1) return answer
def do_register(self, st, d_bit_int, cl): check_bit_int_size(d_bit_int) check_is_binary(st, cl) if st == 1 and cl == 0: self.internal_value = d_bit_int elif cl == 1: self.output_value = self.internal_value self.update_value_label_text() return self.output_value
def gate_and_bit_int_into_one(a_bit_int): """ ANDs all the bits in the provided integer together """ check_bit_int_size(a_bit_int) # TODO: This could be optimized to just use an if statement a_list = convert_num_to_bit_list(a_bit_int) answer = a_list[0] for i in range(1, len(a_list)): answer = gate_and(answer, a_list[i]) return answer
def gate_not_bit_int(a_bit_int): check_bit_int_size(a_bit_int) return ~a_bit_int
def gate_and_bit_ints(a_bit_int, b_bit_int): """ ANDs each bit together between the integers """ check_bit_int_size(a_bit_int, b_bit_int) return a_bit_int & b_bit_int
def select_bit_int(s, a_1_bit_int, a_0_bit_int): check_bit_int_size(a_1_bit_int, a_0_bit_int) check_is_binary(s) return a_1_bit_int if s == 1 else a_0_bit_int
def is_negative_bit_int(a_bit_int): check_bit_int_size(a_bit_int) return int(a_bit_int < 0)
def equal_zero_bit_int(a_bit_int): check_bit_int_size(a_bit_int) return int(a_bit_int == 0)