Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Integer overflow

by almut (Canon)
on Apr 24, 2009 at 00:21 UTC ( [id://759704]=note: print w/replies, xml ) Need Help??


in reply to Re: Integer overflow
in thread Integer overflow

I think this would only work on 32-bit machines (or rather, 32-bit perls).  At least, on my 64-bit box, I get 2158052273.

Replies are listed 'Best First'.
Re^3: Integer overflow
by syphilis (Archbishop) on Apr 24, 2009 at 00:40 UTC
    At least, on my 64-bit box, I get 2158052273

    Yes, on my 64-bit build on linux (32-bit architecture) I'd have to use your solution.

    On an architecture where sizeof(long)==8, I would think that neither solution would work. (This is probably, though not necessarily, an irrelevant observation in the context of what the op needs :-)

    Cheers,
      On an architecture where sizeof(long)==8, I would think that neither solution would work.

      I think (or actually, I'm pretty sure, because on my system, sizeof(long)==8) the pack/unpack solution would work, because pack "l" always (by definiton) is 32-bit, independent of what long might be on the system/C compiler, otherwise.

        pack "l" always (by definiton) is 32-bit

        Yes, you're right (should'er known). According to the docs, the i and I specifiers take note of what the C compiler regards as an 'int', but the l and L types are always 32-bit.

        Sheesh ... you just can't take *anything* for granted :-)

        Cheers,
        Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-24 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found