February 2012
Intermediate to advanced
1184 pages
37h 17m
English
The bit-shift operators (<<
and >>) return the value of the left argument shifted to the left
(<<) or to the right (>>) by the number of bits specified by the
right argument. The arguments should be integers. For example:
1 << 4; # returns 16 32 >> 4; # returns 2
Be careful, though. Results on large (or negative) numbers may vary
depending on the number of bits your machine uses to represent integers.
You can avoid this restriction with the bigint pragma.
use v5.14;
say 500 << 20; # prints 524288000
say 500 << 200; # prints (only) 128000
use bigint;
say 500 << 200;
803469022129495137770981046170581301261101496891396417650688000Read now
Unlock full access