Esempio n. 1
0
 def on_btn_z_sub_released(self):
     try:
         z1 = self.get_z_z(1)
         z2 = self.get_z_z(2)
         result = integer.SUB_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_sub():
    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 subtraction of integer numbers',
                       layout,
                       size=(460, 260),
                       resizable=True)
    while True:
        event, values = window.read()
        if event == "start":
            window['out'].update(
                ListToStr(
                    integer.SUB_ZZ_Z(StrToList(values['dig1']),
                                     StrToList(values['dig2']))))
        if event == sg.WINDOW_CLOSED:
            break
def DIV_PP_P(coefficient1, power1, coefficient2, power2):
    # Деление многочленов
    # Аносов Павел
    new_power = []
    new_coefficient = []
    try:
        while integer.SUB_ZZ_Z(power1[0], power2[0]) != ['-', 1] and power1:
            new_power.append(nat.SUB_NN_N(power1[0], power2[0]))
            new_coefficient.append(
                rat.DIV_QQ_Q(coefficient1[0], coefficient2[0]))
            coef, pow = MUL_PP_P(coefficient2, power2, [new_coefficient[-1]],
                                 [new_power[-1]])
            coefficient1, power1 = SUB_PP_P(coefficient1, power1, coef, pow)

            del coefficient1[0]
            del power1[0]
    except:
        pass
    return new_coefficient, new_power
Esempio n. 4
0
 def test_different_negative(self):
     number1 = [1, 2, [6, 7]]
     number2 = [0, 2, [8, 2]]
     expect = [1, 3, [4, 0, 1]]
     result = integer.SUB_ZZ_Z(number1, number2)
     self.assertEqual(result, expect)
Esempio n. 5
0
 def test_positive(self):
     number1 = [0, 2, [6, 7]]
     number2 = [0, 2, [8, 2]]
     expect = [0, 2, [8, 4]]
     result = integer.SUB_ZZ_Z(number1, number2)
     self.assertEqual(result, expect)
Esempio n. 6
0
 def test_equal_negative(self):
     number = [1, 3, [5, 2, 6]]
     expect = [0, 1, [0]]
     result = integer.SUB_ZZ_Z(number, number)
     self.assertEqual(result, expect)
Esempio n. 7
0
 def test_zeros(self):
     zero = [0, 1, [0]]
     expect = zero
     result = integer.SUB_ZZ_Z(zero, zero)
     self.assertEqual(result, expect)