4 ms·
Reminds me of the way Java's binary search computes the average: int mid = (low + high) >>> 1; This was a fix because the original code had a bug: int mi
by luc4sdreyer 10y ago
Reminds me of the way Java's binary search computes the average:
int mid = (low + high) >>> 1;
This was a fix because the original code had a bug:
int mid =(low + high) / 2;
Which was part of the Java code base for many years. Joshua Bloch based the code on Programming Pearls, which also contained the bug.
More info: https://research.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html https://research.googleblog.com/2006/06/extra-extra-read-all...