Syntactic Confectionery Delight | |
PerlMonks |
Re: How to do popcount (aka Hamming weight) in Perlby Athanasius (Archbishop) |
on Sep 24, 2017 at 12:54 UTC ( [id://1199992]=note: print w/replies, xml ) | Need Help?? |
Hello eyepopslikeamosquito, The CPAN module Bit::Fast has a function popcountl, implemented in C, which operates on 64-bit integers and is claimed to be fast. Disclaimer: I haven’t been able to test it because — although I have a 64-bit OS and a 64-bit Perl with USE_64_BIT_INT defined — my Perl was apparently built with LONGSIZE defined as 4, not 8, so (with use Config) $Config{longsize} == 4 and popcountl doesn’t get built. I confess I don’t understand the issues involved here — maybe just a configuration problem? Anyway, hope that’s of interest,
In Section
Seekers of Perl Wisdom
|
|