"Dharshana Eswaran" schreef:

> $input = 23;     #any decimal value
> $hex1 = sprintf ("%x",$input);
> $binary = unpack 'B*', pack 'H*', $hex1;
> @fields1 = unpack 'A4A4', $binary;
> print "$fields1[1]   $fields1[0]";    # i need to print the Lower
> Nibble first and then the Higher nibble
> 
> But this logic does not work with single digit number as input. When
> i give a single digit number (for eg: 5) as input, it is stored as
> 01010000 in $binary variable instead of 00000101.

$hex1 = sprintf q{%02X}, $input ; 

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to