3 ms·
The implementation of the binary_search algorithm (https://github.com/nzakas/computer-science-in-javascript/blob/master/algorithms/searching/binary-search/binar
by lbolla 15y ago
The implementation of the binary_search algorithm (https://github.com/nzakas/computer-science-in-javascript/blob/master/algorithms/searching/binary-search/binary-search.js https://github.com/nzakas/computer-science-in-javascript/blo...) is bugged by the infamous (http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html http://googleresearch.blogspot.com/2006/06/extra-extra-read-...) "integer overflow" bug:
middle = Math.floor((stopIndex + startIndex)/2);
- Tuna-Fish 15y agoNo, it's not. Because JS has no integers -- stopIndex and startIndex are doubles.
- kenjackson 15y agoSo then the less infamous double overflow problem. :-)
- tybris 15y agoI dare you to make an array of length 2^52 in Javascript.