3 ms·
You can implement 0 prefix checking pretty easily in bitstrings: 0 == hash >> (hash_length - prefix_length) Or, alternatively: !(hash & prefix_mask)
by SomeStupidPoint 9y ago
You can implement 0 prefix checking pretty easily in bitstrings:
0 == hash >> (hash_length - prefix_length)
Or, alternatively:
!(hash & prefix_mask)
where `prefix_mask` is 1111..000, with `prefix_length` number of 1s.
I think that working in terms of bitstrings generated by the hash gives more context to why those integers are chosen (that they represent a certain portion of the space of possible answers), but it's also a matter of taste/background.
- vog 9y agoThis is still more combersome yet less precise than a straight greater-than check.