title: Unbound Integer Class
body: <p>I am implementng an UnboundInteger class which behaves as regular integers.
  The idea is to be able to do operations over arbitrarily large
  integers which do not have any limits on either side as to the
  supported size.</p>
  
  <p>Here is my code</p>
  
  <pre><code>class UnboundInteger(object):
  
  def __init__(self, integer):
      self.integer = str(integer)
  
  
  def __add__(self, other):
      carry = '0'
      temp = '0'
      result = ''
  
      if (len(self.integer) &gt; len(other.integer)):
          num_of_zeros = len(self.integer) - len(other.integer)
          other.integer = '0' * num_of_zeros + other.integer
  
      elif (len(self.integer &lt; other.integer)):
          num_of_zeros = len(other.integer) - len(self.integer)
          self.integer = '0' * num_of_zeros + self.integer
  
      for i in range(1, len(self.integer)+1):
          temp = str(int(self.integer[-i]) + int(other.integer[-i]) + int(carry))
          temp = '0' + temp
          temp = temp[-1]
          carry = temp[-2]
          result = temp + result
  
      return UnboundInteger(result)
  
  
  
  @classmethod
  def from_int(cls, integer):
      '''\
      Take in a integer and build the unbound integer object.
      '''
      ub_integer = cls(integer)
      return ub_integer
  </code></pre>
  
  <p>Unfortunately I am unable to debug the error
  Please help me out</p>
  
  <p>Here is the error</p>
  
  <pre><code>    In [40]: reload(test)
  Out[40]: &lt;module 'test' from 'test.py'&gt;
  
  In [41]: a = test.UnboundInteger(1000000000000)
  
  In [42]: b = test.UnboundInteger(20000000000)
  
  In [43]: a + b
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-43-f96fb8f649b6&gt; in &lt;module&gt;()
  ----&gt; 1 a + b
  
  /home/neel101/test.py in __add__(self, other)
       17             temp = '0' + temp
       18             temp = temp[-1]
  ---&gt; 19             carry = temp[-2]
       20             result = temp + result
       21 
  
  IndexError: string index out of range
  </code></pre>
  
  <p>Or any better approach for this problem. Please let me know!</p>