In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Chris Fedde) wrote:
> -This does the same thing:
> +Using perl's built in conversion of 0x notation:
> - $decimal = ord(pack('B8', '10110110'));
> + $int = 0xDEADBEEF;
> + $dec = sprintf("%d", $int);
perhaps the simple pack() example can be left in, but down
in the bin to dec section right above the following example
which is a bit more complicated:
> + $int = unpack("N", pack("B32",
> + substr("0" x 32 . "11011110101011011011111011101111", -32)));
> + $dec = sprintf("%d", $int);
> +
what's with the substr? i tried this a few places with and without
the substr and always got the same answer. is this a portability
issue (and why doesn't the N format handle that)? maybe i'm missing
something because i do not do this sort of thing a lot.
other than that i like it :).
--
brian d foy <[EMAIL PROTECTED]> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html