in reply to Re^3: Integer overflow
in thread Integer overflow

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.

Replies are listed 'Best First'.
Re^5: Integer overflow
by syphilis (Archbishop) on Apr 24, 2009 at 01:15 UTC
    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