From fb7e9cdd4113e4cf1a43224b3f50ca540d8fc1b4 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Fri, 17 Jul 2015 11:12:42 +0300 Subject: perldelta tweaks on the shift. --- pod/perldelta.pod | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 06e638f35c..6be1dccfe3 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -27,7 +27,7 @@ here, but most should go in the L section. [ List each enhancement as a =head2 entry ] -=head2 Integer shift (C<< << >> and C<< >> >>) now explicitly defined +=head2 Integer shift (C<< << >> and C<< >> >>) now more explicitly defined Negative shifts are reverse shifts: left shift becomes right shift, and right shift becomes left shift. @@ -38,7 +38,7 @@ C, in which case the result is -1 (arithmetic shift). Until now negative shifting and overshifting have been undefined because they have relied on whatever the C implementation happens -to do. For example, for the "overshift" a common behavior C is +to do. For example, for the overshift a common C behavior is "modulo shift": 1 >> 64 == 1 >> (64 % 64) == 1 >> 0 == 1 # Common C behavior. @@ -47,8 +47,14 @@ to do. For example, for the "overshift" a common behavior C is Now these behaviors are well-defined under Perl, regardless of what the underlying C implementation does. Note, however, that you cannot -escape the native integer width. If you need more bits on the left shift, -you could use the C pragma. +escape the native integer width, you need to know how far left you +can go. You can use for example: + + use Config; + my $wordbits = $Config{uvsize} * 8; # Or $Config{uvsize} << 3. + +If you need a more bits on the left shift, you can use for example +the C pragma, or the C module from CPAN. =head2 Postfix dereferencing is no longer experimental -- cgit v1.2.1