The best way to think about the comparison is IMHO to have three possible values for a bit: zero, one, and "don't care". Don't care means that the bit matches both zero and one, it does not matter to a match. Let's use "*" for don't care.
Now, with "don't care" bits, you represent addresses/masks as bits in the masked parts, and don't care in the rest. E.g., a prefix 63.168.52.0/24 becomes 00111111.10101000.00110100.********, where the ******** matches any combination of 8 bits. Obviously, default route 0.0.0.0/0 becomes 32 don't care bits (32 stars) and matches any combination of bits.
IP table should implement longest prefix match, i.e., out of all matches (with don't care bits there will be more than one match, default route matches them all), the match with the least number of don't care bits should be selected. So, if the route matches both 63.168.52.* and ..., the former one is selected, because it has less "*" in it (aka longer prefix).
This of course raises the question on how to implement this. No, it is not just a comparison search. There is a special hardware, called TCAM (ternary content addressable memory). Content-adressable memory allows addressing memory based on content (think of it like searching in a table, based on content of the cell instead or row index). Ternary one, allows said content (cells) to be 'don't care bits' (match both one and zero). In software one have specialized data structures. One common datastructure is called trie, which is a tree like structure which can be used to do longest prefix match on variable length prefixes.