Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: 5x6-bit values into/out of a 32-bit word

by grinder (Bishop)
on Mar 18, 2007 at 09:22 UTC ( #605340=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $num = shift;
    my $bits = 6;
    ...
        ($num & $mask << $_ * $bits)
        >> $_ * $bits
    } 0..$bits-1;
    
  2. or download this
    my $num    = shift;
    my $groups = 5;
    ...
        ($num & $mask << $_ * $bits)
        >> $_ * $bits
    } 0..$groups-1;
    
  3. or download this
    my @in  = (30, 14, 27, 2, 17);
    my $width  = 6;
    ...
    my $offset = 0;
    my $out = 0;
    $out |= ($_ << ($offset++ * $width)) for @in;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-07-11 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (224 votes), past polls