Fixed possible overflow error for large arrays in binary search. #1

Merged
merged 1 commit into from Sep 30, 2011

Conversation

Projects
None yet
4 participants
Contributor

joshzimmerman commented Sep 30, 2011

(left+right)/2 can overflow in the case where, for example, left = 2 and right = 2^(32)-1. In that case, left + (right-left)/2 would not overflow.

@duiker101 duiker101 added a commit that referenced this pull request Sep 30, 2011

@duiker101 duiker101 Merge pull request #1 from joshzimmerman/patch-1
Fixed possible overflow error for large arrays in binary search.
12f6c6b

@duiker101 duiker101 merged commit 12f6c6b into duiker101:master Sep 30, 2011

But why?

Love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment