Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Extracting Bit Fields (Again)

by BrowserUk (Patriarch)
on Oct 12, 2005 at 09:32 UTC ( [id://499435]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl> printf "%b\n", 162;;
    10100010
    ...
    1 011 0100
    perl> print unpack 'B1B3B4', 162;; ## In case of different endian mach
    +ines.
    0 001 0011
    
  2. or download this
    perl> print unpack '(B8)4', pack 'N', 0b11111111_10101010_01010101_000
    +00000;;
    11111111 10101010 01010101 00000000
    
    perl> print unpack '(B4)4', pack 'N', 0b11111111_10101010_01010101_000
    +00000;;
    1111 1010 0101 0000
    
  3. or download this
    perl> print unpack '(B16)2', pack 'N', 0b11111111_10101010_01010101_00
    +000000;;
    1111111110101010 0101010100000000
    
    perl> print unpack '(B12)2', pack 'N', 0b11111111_10101010_01010101_00
    +000000;;
    111111111010 010101010000
    
  4. or download this
    perl> print unpack '(b8)3', pack 'V', 162;;
    01000101 00000000 00000000
    
    perl> print unpack 'b1 b3 b4', pack 'V', 162;;
    0 000 0000
    
  5. or download this
    perl> print unpack '(B8)3', 162;;
    00110001 00110110 00110010
    
    perl> print unpack 'B1B3B4', 162;;
    0 001 0011
    
  6. or download this
    perl> print unpack 'B1B3B4', '162';;
    0 001 0011
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found