Seache
Hello! Thank you for providing the code. We defined a list of subnet ranges and is is working well. Now we added a bunch of single IP addresses to the list with subnet mask 32 and for those the `belongsToSubnet` function is returning `false`. I debugged the sorted list and I think that the issue seems to be in the binary search, because for those IP addresses which returned false, the wrong list entry was compared. So it compares the list entry which is assigned to the `x` variable, but the actual IP list entry is stored in the `y` variable. The list has 69 elements. So now I just check both variables and it is working: ``` // Binary search var x = 0, y = list.length, middle; while (y - x > 1) { middle = Math.floor((x + y) / 2); if (list[middle][0] < ip) x = middle; else y = middle; } // Match var maskedX = ip & list[x][1]; var maskedY = ip & list[y][1]; // check x and y value if(((maskedX ^ list[x][0]) === 0) || ((maskedY ^ list[y][0]) === 0)) { return true; } else { return false; } ``` But shouldn't the results of the binary search (`x` & `y`) actually be the same? So that you can always just check the `x` value. Do you know the reason for this behaviour? Maybe this has to do with the fact that the middle value is always rounded down? Thank you!