I just learned that Java has an unsigned right shift operator >>> from an article cited as a reference in that Wikipedia section. The article has some more details on the subtleties of binary search. For instance, the 20 year old bug in an algorithm proven to be correct was down to integer ranges:
int mid = (low + high)/2;
breaks (obviously in retrospect, am I missing something?) for
low + high > Integer.MAX_INTEGER
It can be replaced by the elegant (but to me, somewhat oblique)
int mid = (low + high) >>> 1;
http://googleresearch.blogspot.de/2006/06/extra-extra-read-a...Also from that page, here's the link to the bug in Sun's tracker, priority 2-High, evaluation: "Can't even compute average of two ints" is pretty embarrassing.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5045582