def RED_Q_Q(Q): # Гурьянов Савелий # Сокращение дроби if integer.POZ_Z_D(Q[0]): nod = nat.GCF_NN_N(integer.ABS_Z_N(Q[0]), integer.ABS_Z_N( Q[1])) # Делим числитель и знаменатель на их НОД Q[0] = integer.DIV_ZZ_Z(Q[0], nod) Q[1] = integer.DIV_ZZ_Z(Q[1], nod) return Q else: return Q
def on_btn_z_div_released(self): try: z1 = self.get_z_z(1) z2 = self.get_z_z(2) result = integer.DIV_ZZ_Z(z1, z2) self.add_history_record('%d / %d = %d' % ( common.Z_to_num(z1), common.Z_to_num(z2), common.Z_to_num(result), )) except Exception as e: self.on_exception(e)
def open_window_int_quot(): layout = [[sg.Text('Enter two integers')], [sg.Input(key='dig1')], [sg.Button('/', key='start')], [sg.Input(key='dig2')], [sg.Text(size=(400, 10), key='out')]] window = sg.Window('The quotient of integer numbers', layout, size=(460, 260), resizable=True) while True: event, values = window.read() if event == "start": window['out'].update( ListToStr( integer.DIV_ZZ_Z(StrToList(values['dig1']), StrToList(values['dig2'])))) if event == sg.WINDOW_CLOSED: break
def test_less_negative_both(self): number1 = [1, 1, [4]] number2 = [1, 2, [1, 2]] expect = [0, 1, [1]] result = integer.DIV_ZZ_Z(number1, number2) self.assertEqual(result, expect)
def test_less_positive(self): number1 = [0, 1, [4]] number2 = [0, 2, [1, 2]] expect = [0, 1, [0]] result = integer.DIV_ZZ_Z(number1, number2) self.assertEqual(result, expect)
def test_normal_negative_both(self): number1 = [1, 3, [4, 2, 5]] number2 = [1, 2, [3, 5]] expect = [0, 2, [0, 1]] result = integer.DIV_ZZ_Z(number1, number2) self.assertEqual(result, expect)
def test_normal_positive(self): number1 = [0, 3, [4, 2, 5]] number2 = [0, 2, [3, 5]] expect = [0, 1, [9]] result = integer.DIV_ZZ_Z(number1, number2) self.assertEqual(result, expect)
def test_one_negative(self): number = [1, 3, [4, 2, 5]] one = [1, 1, [1]] expect = [0, 3, [4, 2, 5]] result = integer.DIV_ZZ_Z(number, one) self.assertEqual(result, expect)
def test_equal_positive(self): number = [0, 3, [4, 2, 5]] expect = [0, 1, [1]] result = integer.DIV_ZZ_Z(number, number) self.assertEqual(result, expect)
def test_zero(self): number = [0, 2, [3, 5]] zero = [0, 1, [0]] expect = zero result = integer.DIV_ZZ_Z(zero, number) self.assertEqual(result, expect)