in reply to converting hex to decimal

# convert to decimal using hex function my $bitmask = hex(82); printf "Dec $bitmask (%b)\n", $bitmask, $bitmask; # mask off bits we want with binary and my $val1 = $bitmask & 192; # 192 is 11000000 bin # bitshift 6 to right to discard insignificant bits $val1 >>= 6; print "Val1 = $val1\n"; print "Val2 = ", $bitmask & 63; # 63 is 111111 bin __DATA__ Dec 130 (10000010) Val1 = 2 Val2 = 2

cheers

tachyon

Replies are listed 'Best First'.
Re: Re: converting hex to decimal
by da97mld (Initiate) on Nov 04, 2003 at 12:04 UTC
    Thanks!! I Appreciate your help! Cheers, Mathias