News for hackers. Stuff that matters.
Re:Nearly All Binary Searches and Mergesorts Are Broken (2006) by Cpoll on Saturday July 23, 2016 @02:54PM (#12150558)
> int mid = low + ((high - low) / 2);

Why this instead of the more intuitive `low/2 + high/2` ?

Edit: Nevermind, I get it. The reason is instructive: In the case where high and low are odd numbers, the "more intuitive" way is off by one.

There are no comments on this comment yet.