3 ms·
to save you time, this is a summary of the links various people here are posting: popcnt of a word counts the number of bits that are "1" https://www.talkches
by fsckboy 2y ago
to save you time, this is a summary of the links various people here are posting:
popcnt of a word counts the number of bits that are "1"
https://www.talkchess.com/forum3/viewtopic.php?t=38521 https://www.talkchess.com/forum3/viewtopic.php?t=38521
the NSA wanted to do cryptanalysis on intercepted messages, and since the CDC 6000 had 60-bit words, one word was enough to store most alphabets they were interested in. They were able to:
Split a message into lines
Set a bit for each unique character they encountered per line
Use popcount to count the distinct characters
Use the count as a hash for further cryptanalysis
Curiously, popcount seems to have disappeared from instruction sets between the mid-1970s and the mid-2000s.
(of course for all we know this could be NSA disinformation ;)
That's the answer to the NSA question. There are other uses described here https://vaibhavsagar.com/blog/2019/09/08/popcount/ https://vaibhavsagar.com/blog/2019/09/08/popcount/ including for Hamming codes and Neural nets and more.