Although binary search is straightforward, the details can be tricky
en.wikipedia.org
en.wikipedia.org
I'm pretty sure I read both the Knuth, Bentley and Bloch notes about this at some point, and basically made the quote part of my beliefs system :-).
The article from J. Bloch also makes for an interesting, short read [1]. In a nutshell the piece of the algorithm that implements the pivot index is often implemented like this:
int mid = (low + high) / 2;
... which is incorrect because (low + high) introduce the risk of overflow for big enough indexes overflowing the int capacity. Possible solution:
int mid = low + ((high - low) / 2);
1: http://googleresearch.blogspot.com/2006/06/extra-extra-read-...