in reply to Bitwise & with large numbers
UPDATE: thanks tachyon!use strict; for (0..20,) { $a = dec2bin($_+1); $b = dec2bin($_); print "$a = ", $_ + 1, "\n", "$b = ", $_, "\n", "--------\n", dec2bin(($_+1) & $_), " = ", (($_+1) & $_), "\n\n"; } # Perl Cookbook recipe 2.4. sub dec2bin { my $s = unpack("B32", pack("N",shift)); #$s =~ s/^0+(?=\d)//; $s = substr($s,-8,8); return $s; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)-->
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Bitwise & with large numbers
by tachyon (Chancellor) on Apr 03, 2002 at 04:29 UTC |