Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Converting Hexadecimal to Decimal notation and vice-versa

by stonecolddevin (Vicar)
on Oct 17, 2009 at 21:51 UTC ( #801809=note: print w/ replies, xml ) Need Help??


in reply to Converting Hexadecimal to Decimal notation and vice-versa

I think pack could take care of this as well.

UPDATE: Here's an example1:

$int = unpack("N", pack("H8", substr("0" x 8 . "DEADBEEF", -8)));
$dec = sprintf("%d", $int);

Where DEADBEEF is your hex number.

1http://perl.active-venture.com/pod/perlfaq4-datanumber.html

mtfnpy


Comment on Re: Converting Hexadecimal to Decimal notation and vice-versa
Select or Download Code
Re^2: Converting Hexadecimal to Decimal notation and vice-versa
by AnomalousMonk (Abbot) on Oct 18, 2009 at 11:53 UTC
    But how does this apply to the big integers of the OP?
    >perl -wMstrict -le "my $int = unpack('N', pack('H8', '102030405060708090a0b0c0d0e0f')); my $dec = sprintf('%d', $int); print $dec; " 270544960

      Specify a different template for sprintf?

      mtfnpy

        Can you give an example?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://801809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2014-10-23 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (129 votes), past polls