title: Why java Arrays.binarySearch return (-(insertion point) - 1) when not found
body: <p>I currently try to learn java Arrays.binarySearch, and see Oracle doc below:</p>
  
  <pre><code>Arrays.binarySearch(int[] a, int fromIndex, int toIndex, int key)
  </code></pre>
  
  <p>Returns:</p>
  
  <blockquote>
    <p>index of the search key, if it is contained in the array within the
    specified range; otherwise, (-(insertion point) - 1)**</p>
  </blockquote>
  
  <p>When not found, I don't know why return -(insertion point) - 1 here? Why not just return -1 or -(insertion point)? What's the idea for -(insertion point) - 1?</p>