mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 01:35:16 +08:00
prevent (ub+lb) overflow
This commit is contained in:
@ -23,7 +23,7 @@ class BinarySearch
|
||||
if ( lb > ub)
|
||||
return -1;
|
||||
|
||||
int mid = (ub+lb)/2;
|
||||
int mid = (ub+lb) >>> 1;
|
||||
int comp = key.compareTo(array[mid]);
|
||||
|
||||
if (comp < 0)
|
||||
|
Reference in New Issue
Block a user