Ejemplo n.º 1
0
 def __add__(self, other):
     if isinstance(other, int):
         return self.xor_int(other)
     else:
         if not isinstance(other, sbits):
             other = sbits(other)
             n = self.n
         else:
             n = max(self.n, other.n)
         res = self.new(n=n)
         inst.xors(n, res, self, other)
         return res
Ejemplo n.º 2
0
 def __add__(self, other):
     if isinstance(other, int):
         return self.xor_int(other)
     else:
         if not isinstance(other, sbits):
             other = sbits(other)
         n = min(self.n, other.n)
         res = self.new(n=n)
         inst.xors(n, res, self, other)
         max_n = max(self.n, other.n)
         if max_n > n:
             if self.n > n:
                 longer = self
             else:
                 longer = other
             bits = res.bit_decompose() + longer.bit_decompose()[n:]
             res = self.bit_compose(bits)
         return res
Ejemplo n.º 3
0
 def __add__(self, other):
     if isinstance(other, int):
         return self.xor_int(other)
     else:
         if not isinstance(other, sbits):
             other = sbits(other)
         n = min(self.n, other.n)
         res = self.new(n=n)
         inst.xors(n, res, self, other)
         max_n = max(self.n, other.n)
         if max_n > n:
             if self.n > n:
                 longer = self
             else:
                 longer = other
             bits = res.bit_decompose() + longer.bit_decompose()[n:]
             res = self.bit_compose(bits)
         return res
Ejemplo n.º 4
0
 def __add__(self, other):
     if isinstance(other, int) or other is None:
         return self.xor_int(other)
     else:
         if not isinstance(other, sbits):
             other = self.conv(other)
         if self.n is None or other.n is None:
             assert self.n == other.n
             n = None
         else:
             n = min(self.n, other.n)
         res = self.new(n=n)
         inst.xors(n, res, self, other)
         if self.n != None and max(self.n, other.n) > n:
             if self.n > n:
                 longer = self
             else:
                 longer = other
             bits = res.bit_decompose() + longer.bit_decompose()[n:]
             res = self.bit_compose(bits)
         return res