From: Jarkko Hietaniemi Date: Sun, 6 May 2001 13:24:12 +0000 (+0000) Subject: Document the undefinedness of bitshifting out of range. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b16cf6df0ad46b829f1ecf5de2fff8df6f195f73;p=p5sagit%2Fp5-mst-13.2.git Document the undefinedness of bitshifting out of range. p4raw-id: //depot/perl@10006 --- diff --git a/pod/perlop.pod b/pod/perlop.pod index 5cfdb4a..ec96f04 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -233,6 +233,18 @@ Binary ">>" returns the value of its left argument shifted right by the number of bits specified by the right argument. Arguments should be integers. (See also L.) +Note that both "<<" and ">>" in Perl are implemented directly using +"<<" and ">>" in C. If C (see L) is +in force then signed C integers are used, else unsigned C integers are +used. Either way, the implementation isn't going to generate results +larger than the size of the integer type Perl was built with (32 bits +or 64 bits). + +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, C<< 1 << 32 >> is undefined. Shifting by a negative number +of bits is also undefined. + =head2 Named Unary Operators The various named unary operators are treated as functions with one