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 );
In reply to Re^3: Trying to translate overflowing JS code to Perl
by Corion
in thread Trying to translate overflowing JS code to Perl
by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |