Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend documentation of shift operators in perlop.pod. #22861

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

sisyphus
Copy link
Contributor

The perlop.pod documentation for "Shift Operators" implied that "all bits would fall off" if the size of the bit-shift was greater than the bitsize of the integer.
AFAICT, "all bits fall off" if the size of the bit-shift is greater than or equal to the bitsize of the integer.
So I've made that correction.

There was also some waffle about what C does. I've reduced that to the pre-existing statement This is unlike in C, where shifting by too many bits is undefined. because I think the rest is irrelevant.

And there was also the incorrect statement:

print 20 << 40;  # 5120 on 32-bit machines,

which I've changed to:

print 20 << 32;  # 0 on 32-bit machines,

  • This set of changes does not require a perldelta entry.

1 >> 64 == 1 >> (64 % 64) == 1 >> 0 == 1 # Common C behavior.

but that is completely accidental.
Shifting by a value greater than or equal to integer size (in bits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/integer/the &/

Copy link
Contributor

@khwilliamson khwilliamson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm other than the nit

@khwilliamson khwilliamson merged commit 7496ff1 into Perl:blead Dec 18, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants