node -e 'console.log(1<<30);' 1073741824 echo $((1<<30)) 1073741824 # same result perl -e 'print 1<<30, "\n"' 1073741824 # same result node -e 'console.log(1<<31);' -2147483648 # overflow in 32bit! echo $((1<<31)) 2147483648 # correct result perl -e 'print 1<<31, "\n"' 2147483648 # same result # to obtain the overflow in bash echo $((1<<63)) -9223372036854775808 # overflow in 64bit # still perl does not perl -e 'print 1<<63, "\n"' 9223372036854775808 perl -e 'print 1<<64, "\n"' 0 # gotcha! # this is when I realised the problem: node -e 'console.log(1169367104<<5);' -1234958336 echo $((1169367104<<5)) 37419747328 perl -e 'print 1169367104<<5, "\n"' 37419747328 # same result #### use Test::More; is(1169367104<<5, -1234958336, "simulated JS 32bit shift."); done_testing;