# 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
In reply to Re: converting hex to decimal
by tachyon
in thread converting hex to decimal
by da97mld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |