Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
tromp
· 3y ago · 0 comments
if a > b { mid = (a-b)/2
That only avoids overflow on unsigned types (where it would be called wraparound) ...
Comments
[–]
eloff
3y ago
The point of the midpoint calculation is to find the mid-index usually (e.g. binary search, quicksort). So a and b would be unsigned. You're right about signed integers though.