Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 perusing the Monastery: (10)
As of 2014-09-22 21:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (204 votes), past polls