On Thursday, 13 February 2020 at 07:49:13 UTC, Adnan wrote:
However my test fails saying something like:
source/binary_search.d(33): [unittest] 18446744073709551615 != 1
core.exception.AssertError@source/binary_search.d(33):
18446744073709551615 != 1
What's causing this underflow?
It's ulong
I am debugging my simple binary search (I still am):
module binary_search;
debug {
static import std;
}
int indexOf(T)(const T[] list, const T key) {
ulong lo = 0;
ulong hi = list.length - 1;
while (hi > lo) {
const ulong mid = lo + (hi - lo) / 2;
if (list[mid] >