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

Re2: Nibble swap

by blakem (Monsignor)
on Oct 04, 2002 at 20:45 UTC ( #202891=note: print w/replies, xml ) Need Help??


in reply to Re: Nibble swap
in thread Nibble swap

That would be great if << and >> worked on bits, but I don't think they do.
% perl -le 'print "5" << 4' 80
i.e. 5*2^4 == 80

-Blake

Replies are listed 'Best First'.
Re^3: Nibble swap
by Aristotle (Chancellor) on Oct 04, 2002 at 20:53 UTC
    Doh, you're right. But
    $ perl -le 'print ord("5") << 4' 848
    Though I'm not sure we can just say my $swapped = (ord($_) << 4 | ord($_) >> 4) & 0xFF;
    to fix it. (Don't seem to be able to wrap my head around it right now.)

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2019-08-25 06:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?