Fix integer rounding bug in bsearch