[pgh-pm] 64 bit hex() function

Benjamin R. Haskell pm at benizi.com
Wed Aug 29 07:30:57 PDT 2007


WorksForMe, with the caveat that there's a warning:

64$ perl -lwe 'print sprintf "%16x", hex "123456789abcdef0"'
Hexadecimal number > 0xffffffff non-portable at -e line 1.
123456789abcdef0

# can disable the warning:
64$ perl -lwe 'no warnings "portable"; print sprintf "%16x", hex "123456789abcdef0"'
123456789abcdef0

64$ perl -v | grep built
This is perl, v5.8.5 built for x86_64-linux-thread-multi
# not my personal machine, hence not 5.8.8+

My first instinct would be to check that your perl is built to actually 
_use_ 64 bits.
64$ perl -V | grep use64
     use64bitint=define use64bitall=define uselongdouble=undef

(For comparison, on my 32-bit machine:)
32$ perl -V | grep use64
     use64bitint=undef use64bitall=undef uselongdouble=undef

Other than that, I'm at a loss.

Best,
Ben

On Tue, 28 Aug 2007, beer at cmu.edu wrote:

> We are running a perl application on a 64 bit machine.  We have a piece of
> code that takes a hex number and converts it to decimal for storage.  The
> hex number is an id number from another system.  This system has started
> passing us 64 bit numbers recently.  The new 64 bit values cause an integer
> overflow in the built-in hex() function.
>
> I was not able to find anything via a web search to indicate this is a known
> problem.  Anyone else have experience/insights that might help me around
> this issue?
>
> Thanks
>
> -bill
>


More information about the pgh-pm mailing list