News for hackers. Stuff that matters.
Re:Nearly All Binary Searches and Mergesorts are Broken (2006) by smsm42 on Tuesday November 26, 2013 @03:28AM (#6799916)
That's what I immediately wondered - why it's int and not size_t? Well, I guess in Java engine there could be technical reasons why it is int, but in general case of implementation you'd probably assume it's size_t and then only one of the fixes works.
Re:Nearly All Binary Searches and Mergesorts are Broken (2006) by chj on Tuesday November 26, 2013 @03:33AM (#6799940)
Yes, best fix:

   int mid = low + (high - low) / 2;