Hello Jean-Paul,

Wednesday, July 04, 2001, Jean-Paul Miéville <[EMAIL PROTECTED]> wrote:


JPM> Can you explain me how can I convert an hexadecimal number in decimal ?


unfortunatelly, i do not remember where i got this :(

bin2dec:
 
  $out = unpack("N", pack("B32", substr("0" x 32 . $in, -32))); 
 
bin2hex:
 
  $out = unpack("H8", pack("B32", substr("0" x 32 . $in, -32))); 
 
bin2oct:
 
  $out = sprintf "%o", unpack("N", pack("B32", substr("0" x 32 . $in, -32))); 
 
dec2bin:
 
  $out = unpack("B*", pack("N", $in));
 
dec2hex:
 
  $out = unpack("H8", pack("N", $in));
 
dec2oct:
 
  $out = sprintf "%o", $in;
 
hex2bin:
 
  $out = unpack("B32", pack("N", hex $in));
 
hex2dec:
 
  $out = hex $in;
 
hex2oct:
 
  $out = sprintf "%o", hex $in;
 
oct2bin:
 
  $out = unpack("B32", pack("N", oct $in));
 
oct2dec:
 
  $out = oct $in;
 
oct2hex:
 
  $out = unpack("H8", pack("N", oct $in));
 
Best wishes,
 Maxim                            mailto:[EMAIL PROTECTED]


Reply via email to