http://www.perlmonks.org?node_id=11107872


in reply to Re^2: bit array comparison
in thread bit array comparison

my $i_cnt = () = sprintf("%b", $i) =~ /1/g; my $u_cnt = () = sprintf("%b", $u) =~ /1/g;

Minor point: for simple counting, tr/// (the transliteration operator) is preferred over m//g because it’s more efficient; also, the syntax is cleaner:

my $i_cnt = sprintf('%b', $i) =~ tr/1//; my $u_cnt = sprintf('%b', $u) =~ tr/1//;

Hope that’s of interest,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,