in reply to comparing bit vectors
Is there a better way to see if a bit vector has all its bits set to '0'?
Yes. Combine the checksumming (%nn) and bit (b*) formats of unpack:
## 800 zero bits $bitVec = chr(0) x 100;; print unpack '%32b*', $bitVec;; 0 ## Set 1 bit in the middle substr $bitVec, 50, 1, chr(1);; print unpack '%32b*', $bitVec;; 1 ## set 8 bits in the middle [0] Perl> substr $bitVec, 50, 1, chr(255);; [0] Perl> print unpack '%32b*', $bitVec;; 8
|
|---|