complexitysearching
Avoid overflow when computing a midpoint
Anonymous
In a fixed-width integer type, (lo + hi) / 2 can overflow even when the midpoint fits. For nonnegative bounds where hi - lo fits, lo + (hi - lo) / 2 avoids that sum overflow. Check the division's rounding behavior too.
0