Two-point search is very difficult ah ... The journey is endless. Before reading the first time before the realization of the cycle, the termination of the condition is only to determine whether the mid-value falls within the range. Of course this is wrong, and it's rather stupid.
The second time after the implementation of the network to change the interpretation of the cycle of the condition into the while (L < h), the direct return-1; for my implementation, I made another mistake, this condition will be less compared to an element, that is, less than L = h point to the element.
Finally, I changed the loop condition to the while (L <= h) without a test error.
But maybe my test case might not be completely covered, and I'll continue with the argument tomorrow.
Two-point lookup also has an important error point is the overflow of integer addition ... Do not know how many of the world's bugs are out of the overflow, it must be more to stay in mind.
The solution given in the book is MID = L + ((h-l) >> 1);
is the mathematical formula (A + b)/2 = B + (b-a)/2 to be applied.
I made a mistake---two points to find