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, |
In reply to Re^3: bit array comparison
by Athanasius
in thread bit array comparison
by Amendil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |