Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: bit array comparison

by ikegami (Pope)
on Oct 22, 2019 at 14:19 UTC ( #11107850=note: print w/replies, xml ) Need Help??


in reply to bit array comparison

The problem is that unpack "b*" takes a string of bytes.

And so does unpack "B*", what you'd use to get the bits in the same order as sprintf "%b".

$ perl -e'CORE::say unpack "B*", pack "L>", 3' 00000000000000000000000000000011

Tip: you should use | rather than + to set a bit (in case it's already set).

$b |= 1 << 2;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11107850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2021-04-17 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?