http://qs1969.pair.com?node_id=610880


in reply to bitwise shift operator

The parenthesis control the execution order so the 1 gets shifted left 31 places, then the result is multiplied by 2. Note that this is a trick to get around Perl's internal representation for integers (on many platforms) as 32 bit quantities. Consider:

print 1<<31, "\n"; print 2 * (1<<31), "\n"; print 1<<32, "\n"; print 2**32, "\n";

Prints:

2147483648 4294967296 1 4294967296

Although it's not clear to me why 2**32 was not used - your code seems rather odd to me.


DWIM is Perl's answer to Gödel