3 ms·
These stories always make me think of another bug that is unbelievable. The bug is in Binary Search - one of the most fundamental algorithms in programming. It
by edanm 16y ago
These stories always make me think of another bug that is unbelievable.
The bug is in Binary Search - one of the most fundamental algorithms in programming. It's been around in a published implementation of Binary Search since 1986, and the implementation of Binary Search for the JDK was broken for 9 years. This bug was only discovered in 2006, when someone's program broke.
If you haven't heard of it, read more here: http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html http://googleresearch.blogspot.com/2006/06/extra-extra-read-...
Quick Summary - to get the "middle" element of the array, the line is this: int mid = (low + high) / 2;. This overflows when low + high is larger than MAX_INT, causing havoc.
- tptacek 16y agoThis is an awesome, awesome post. Thanks for sharing it.