calculate hamming distance and weight in sqlite
问题 Is there a good way to calculate hamming distance and weight in sqlite? It supports bit-wise operators but I want to order results based on hamming weight, and there is no support for bitcount in sqlite. To be more elaborate, let's say I have those rows: 1011 1000 1100 0011 and given the 1st row (1011) I would like to get as a result last row (0011) which has the most 1s if you AND them. In my case the numbers will be about 650 digits long, and I have about 3500 rows. I've found this solution