Skip to content

Commit

Permalink
prevent (ub+lb) overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lvncnt authored Oct 1, 2017
1 parent b21444d commit 85771ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Searches/BinarySearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static <T extends Comparable<T>> int BS(T array[], T key, int lb, int ub)
if ( lb > ub)
return -1;

int mid = (ub+lb)/2;
int mid = (ub+lb) >>> 1;
int comp = key.compareTo(array[mid]);

if (comp < 0)
Expand Down

0 comments on commit 85771ea

Please sign in to comment.