[Mono-dev] Patch for fixing binary search
bmaurer at ximian.com
Sun Jun 4 17:41:46 EDT 2006
This also exists for qsort
object objPivot = keys.GetValueImpl ((low + high) / 2);
On Sat, 2006-06-03 at 18:04 -0400, Duncan Mak wrote:
> As pointed out by this blog post by Joshua Bloch:
> The current by-the-book implementation of BinarySearch has an integer
> overflow bug due to this:
> int mid = (low + high) / 2;
> This bug manifests itself when (low + high) > Int32.MaxValue.
> Here's a patch for fixing this in Array, Array<T> and ArrayList.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list