Famously, Jon Bentley's book "Programming Pearls" binary search contained an overflow error. See "Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken" at https://ai.googleblog.com/2006/06/extra-extra-read-all-about... which includes:
> Fast forward to 2006. I was shocked to learn that the binary search program that Bentley proved correct and subsequently tested in Chapter 5 of Programming Pearls contains a bug. Once I tell you what it is, you will understand why it escaped detection for two decades. Lest you think I'm picking on Bentley, let me tell you how I discovered the bug: The version of binary search that I wrote for the JDK contained the same bug. It was reported to Sun recently when it broke someone's program, after lying in wait for nine years or so.