Just goes to show how HARD programming really is and if anyone tells you otherwise they are lying LOL:
I was amazed: given ample time, only about ten percent of professional programmers were able to get this small program right. But they aren’t the only ones to find this task difficult: in the history in Section 6.2.1 of his Sorting and Searching, Knuth points out that while the first binary search was published in 1946, the first published binary search without bugs did not appear until 1962.
– Jon Bentley, Programming Pearls (1st edition), pp. 35-36.