th0ma5_ander...@yahoo.com wrote:
Hi all,

Hello,

When converting a single number (eg 6) to its binary format using
unpack as in:

unpack 'B8', '6'; # output = 00110110

You are not converting the number 6, you are converting the string '6'.


I get the 8 character output 00110110.
Does unpack have options for it to only return the last 4 characters
of this output (ie 0110)?
Or is the only option to use substr?

$ perl -le'printf "%04b\n", 6'
0110



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to