perlop says
Note that both << and >> in Perl are implemented directly using << and >> in CNot Perl's fault indeed.
[...]
The result of overflowing the range of the integers is undefined because it is undefined also in C. In other words, using 32-bit integers, 1 << 32 is undefined. Shifting by a negative number of bits is also undefined.
perl -E 'say unpack "b*", pack "Q", ( 3<<$_ ) for 60..70;' 0000000000000000000000000000000000000000000000000000000000001100 0000000000000000000000000000000000000000000000000000000000000110 0000000000000000000000000000000000000000000000000000000000000011 0000000000000000000000000000000000000000000000000000000000000001 1100000000000000000000000000000000000000000000000000000000000000 0110000000000000000000000000000000000000000000000000000000000000 0011000000000000000000000000000000000000000000000000000000000000 0001100000000000000000000000000000000000000000000000000000000000 0000110000000000000000000000000000000000000000000000000000000000 0000011000000000000000000000000000000000000000000000000000000000 0000001100000000000000000000000000000000000000000000000000000000
In reply to Re: Perl's bad at arithmetic?
by Eily
in thread Perl's bad at arithmetic?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |