in reply to Re^4: Trying to translate overflowing JS code to Perl
in thread Trying to translate overflowing JS code to Perl

But you're Math::IntAny test script implies that you are seeing: 2147483648 2147483648

Sorry Rob if I was not clear. The test's expected value is what JS outputs (therehore what I expect if I want to simulate JS behaviour). Both tests fail in linux (and as you demonstrated above).

I have edited my main post to say that I have asked some more general question at SO a couple of hours ago here: https://stackoverflow.com/questions/77584450/emulate-javascripts-32bit-signed-integer-arithmetic-to-c-or-perl-some-discr and just now I see there are some responses.

Replies are listed 'Best First'.
Re^6: Trying to translate overflowing JS code to Perl
by syphilis (Archbishop) on Dec 02, 2023 at 01:52 UTC
    The test's expected value is what JS outputs (therefore what I expect if I want to simulate JS behaviour)

    I missed that - more likely through my inattention to detail, than anything else.
    I had also missed that the unpack/pack approach also fails with the same values.

    The integer pragma on a 32-bit perl seemed pretty good, but it fails to emulate on some expressions.
    For example, the expression 1073741824+1073741824 needs to be evaluated outside the integer pragma, whereas the expression 1169367104 << 5 needs to be evaluated inside the integer pragma.

    Cheers,
    Rob