Hacker News new | past | comments | ask | show | jobs | submit login

Implementations of common algorithms are even worse.

The Java binary search implementation had a bug that eluded detection for 9 years, and it was based on a implementation from the 1986 book "Programming Pearls" that also contained the same bug (TL;RD: it's an overflow error that computers in 1986 would probably never have run into - who could imagine having an array with more than 2^30 elements?!).

Even worse: While the first binary search was published in 1946, the first binary search that works correctly for all values of n did not appear until 1962. - and this bug shows it is likely this 1962 version would have failed the same way.

See http://googleresearch.blogspot.com.au/2006/06/extra-extra-re...




Curiously, most c programs with 2^30 element arrays will probably have 64 bit ints, and will therefore work. In the time the code original code was written, I suppose the ints would have been 16 bit?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: