Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: bit array comparison

by ikegami (Patriarch)
on Oct 22, 2019 at 14:19 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found