Spooky has asked for the wisdom of the Perl Monks concerning the following question:

I have the following hex value: BE91CFB586466D02. This converts to decimal 13731985117378145538. When I used a Perl 'hex(unpack("H16"....' on the hex value the resulting Perl output was 1.37319851173781e+19. I'm OK with the 'e+19' value but I'm wondering what happened to the '45538' portion of the value. How can I obtain greater precision?

Replies are listed 'Best First'.
Re: converting large hex values
by mzedeler (Pilgrim) on Jul 30, 2009 at 12:04 UTC

    Thats not directly supported, but the module bignum seems to provide it.

      Thanks - ..at a command line when I enter the following: >perl -Mbignum=a,50 -le 'print 0xbe91cfb586466d02'...it returns: 13731985117378145538 (exactly the value I want). The Perl script I'm running has at the top the following line: #!/fs/COTS/gnu/bin/AIX/perl - followed by the rest of the source code. I'm now wondering how I can introduce the "-Mbignum" statement into the source code in order to get the precision I'm looking for - any ideas? ..thanks
        The simplest thing to try is (as suggested by bignum):
        #!/fs/COTS/gnu/bin/AIX/perl use bignum;