def __div__(self,x): if type(x)==GenBase: if p.frombase(x.value['base'],x.value['value'])==0: print "The divisor can't be zero!" else: div=p.frombase(self.value['base'],self.value['value'])/p.frombase(x.value['base'],x.value['value']) return GenBase(self.value['base'],div) else: raise TypeError
def __sub__(self,x): if type(x)==GenBase: subt = p.frombase(self.value['base'],self.value['value'])-p.frombase(x.value['base'],x.value['value']) if subt<0: print "subtraction is less than 0" else: return GenBase(self.value['base'], subt) else: raise TypeError
def changebase(self,base_new): n = p.frombase(self.value['base'],self.value['value']) m = p.tobase(base_new,n) self.value=dict(base=base_new,value=m)
def modulo(self,x): if type(x)==GenBase: res = p.frombase(self.value['base'],self.value['value'])%p.frombase(x.value['base'],x.value['value']) return GenBase(self.value['base'],res) else: raise TypeError
def __mul__(self,x): if type(x)==GenBase: pro = p.frombase(self.value['base'],self.value['value'])*p.frombase(x.value['base'],x.value['value']) return GenBase(self.value['base'], pro) else: raise TypeError
def __add__(self,x): if type(x)==GenBase: summ = p.frombase(self.value['base'],self.value['value']) + p.frombase(x.value['base'], x.value['value']) return GenBase(self.value['base'], summ) else: raise TypeError