Beispiel #1
0
 def on_btn_n_add1_released(self):
     try:
         n1 = self.get_n_n(1)
         result = natural.ADD_1N_N(n1)
         self.add_history_record('%d + 1 = %d' % (
             common.N_to_num(n1),
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #2
0
 def on_btn_n_lcm_released(self):
     try:
         n1 = self.get_n_n(1)
         n2 = self.get_n_n(2)
         result = natural.LCM_NN_N(n1, n2)
         self.add_history_record('НОК(%d, %d) = %d' % (
             common.N_to_num(n1),
             common.N_to_num(n2),
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #3
0
 def on_btn_n_modn_released(self):
     try:
         n1 = self.get_n_n(1)
         n2 = self.get_n_n(2)
         result = natural.MOD_NN_N(n1, n2)
         self.add_history_record('%d %% %d = %d' % (
             common.N_to_num(n1),
             common.N_to_num(n2),
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #4
0
 def on_btn_n_mulk_released(self):
     try:
         n1 = self.get_n_n(1)
         k = self.get_n_k()
         result = natural.MUL_Nk_N(n1, k)
         self.add_history_record('%d * 10^%d = %d' % (
             common.N_to_num(n1),
             k,
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #5
0
 def on_btn_n_divnd_released(self):
     try:
         n1 = self.get_n_n(1)
         n2 = self.get_n_n(2)
         k = self.get_n_k()
         result = natural.DIV_NN_Dk(n1, n2, k)
         self.add_history_record('%d / (%d * 10^%d) = %d' % (
             common.N_to_num(n1),
             common.N_to_num(n2),
             k,
             result,
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #6
0
 def on_btn_n_subnk_released(self):
     try:
         n1 = self.get_n_n(1)
         n2 = self.get_n_n(2)
         k = self.get_n_k()
         result = natural.SUB_NDN_N(n1, n2, k)
         self.add_history_record('%d - %d * %d = %d' % (
             common.N_to_num(n1),
             common.N_to_num(n2),
             k,
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #7
0
def rational(Q):
    #   if Q[1][0] == 1 and Q[1][1][0] == 1:
    #       return str(common.Z_to_num(Q[0]))

    return '%d/%d' % (
        common.Z_to_num(Q[0]),
        common.N_to_num(Q[1]),
    )
Beispiel #8
0
    def on_btn_n_com_released(self):
        try:
            n1 = self.get_n_n(1)
            n2 = self.get_n_n(2)
            result = natural.COM_NN_D(n1, n2)
            if result == 0:
                sign = '='
            elif result == 1:
                sign = '<'
            else:
                sign = '>'

            self.add_history_record('%d %s %d' % (
                common.N_to_num(n1),
                sign,
                common.N_to_num(n2),
                ))
        except Exception as e:
            self.on_exception(e)
Beispiel #9
0
 def on_btn_z_abs_released(self):
     try:
         z1 = self.get_z_z(1)
         result = integer.ABS_Z_N(z1)
         self.add_history_record('|%d| = %d' % (
             common.Z_to_num(z1),
             common.N_to_num(result),
             ))
     except Exception as e:
         self.on_exception(e)
Beispiel #10
0
    def on_btn_n_nzer_released(self):
        try:
            n1 = self.get_n_n(1)
            result = natural.NZER_N_B(n1)
            sign = '!=' if result else '='

            self.add_history_record('%d %s 0' % (
                common.N_to_num(n1),
                sign,
                ))
        except Exception as e:
            self.on_exception(e)