-
Notifications
You must be signed in to change notification settings - Fork 4
2016 001 Add popCount to WORD signature
John Reppy edited this page May 10, 2016
·
3 revisions
Author: John Reppy
Last revised: May 9, 2016
Status: proposed
Discussion: issue #13
signature WORD
This proposal adds the population-count operation to the WORD
signature.
val popCount : word -> int
popCount w
returns the number of `1` bits in the word `w`.
This operation is useful for computing the Hamming distance between two words and for implementing various data structures (e.g., the Hash array mapped trie). There are two reasons for making it part of the Basis Library:
-
the straight-line implementation depends on the size of the word type.
-
some architectures support the operation in hardware, which can be even faster than the the straight-line code.