in reply to hex to bin
To go the other direction requires you to do a little work. Perl doesn't come with a binary2decimal (or hex) converter, but you can write your own easily:my $bin = sprintf "%b", hex $hex;
sub bin2dec { my @bits = reverse split '', shift; my $num = 0; for( my $i=0; $#bits >= $i; ++$i ) { $num += 2 ** $i if $bits[$i] } return $num } my $hex = sprintf "%x", bin2dec( $bin )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: hex to bin
by merlyn (Sage) on Mar 09, 2001 at 08:47 UTC | |
by Adam (Vicar) on Mar 09, 2001 at 22:44 UTC | |
|
Re: Re: hex to bin
by mt2k (Hermit) on Nov 14, 2002 at 19:30 UTC |