title: binary search middle value calculation
body: <p>The following is the pseudocode I got from a TopCoder tutorial about binary search</p>
  
  <pre><code>binary_search(A, target):
     lo = 1, hi = size(A)
     while lo &lt;= hi:
        mid = lo + (hi-lo)/2
        if A[mid] == target:
           return mid            
        else if A[mid] &lt; target: 
           lo = mid+1
        else:
           hi = mid-1
  
     // target was not found
  </code></pre>
  
  <p>Why do we calculate the middle value as <em>mid = lo + (hi - lo) / 2</em> ? Whats wrong with <em>(hi + lo) / 2</em></p>
  
  <p>I have a slight idea that it might be to prevent overflows but I'm not sure, perhaps someone can explain it to me and if there are other reasons behind this.</p>