in reply to Re^2: Trying to translate overflowing JS code to Perl
in thread Trying to translate overflowing JS code to Perl
I believe you can do the complete calculation without conversion and just at the end downgrade to 32 bit and convert to signed. The following should work:
sub calc_32bit_signed( $value ) { return unpack( "l", pack "L", ($value & 0xffffffff))) } ... say calc_32bit_signed( $n << 6 ); say calc_32bit_signed( $n + 2 );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Trying to translate overflowing JS code to Perl
by syphilis (Archbishop) on Nov 29, 2023 at 11:42 UTC | |
by Corion (Patriarch) on Nov 29, 2023 at 13:22 UTC | |
|
Re^4: Trying to translate overflowing JS code to Perl
by bliako (Abbot) on Nov 30, 2023 at 18:00 UTC |