The intermediate value of start+end may be too large to store in an
integer, even though start and end by themselves are in the valid
range. If you know this to not be the case, you can use the simpler
form.
Don
On Jan 8, 5:04 am, Sanjay Rajpal srn...@gmail.com wrote:
In binary search,
mid =
Exactly. And note that if pointers and unsigned integers have the
same number of bits, overflow can't be a problem as long as the array
elements are 2 bytes or more long. I.e. if you have an n-bit machine,
the last 2-byte array element can't have index more than 2^n/2 - 1 =
2^(n-1) - 1.