Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re2: Nibble swap

by blakem (Monsignor)
on Oct 04, 2002 at 20:45 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://202891]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found