-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Proposal: Circular shift operator #7183
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
Comments
I think the standard meaning of |
For addition, subtraction and multiplication with |
|
@mrakh These have come up as options: rotate right: One can devise variants of these too. rotate right: Not sure about Zig, in my case @ is able to be used in a token like this. |
An option I like is |
No opinion about this, just wanted to note that in Java |
i think we're safe to have |
In my opinion, what we include as fundamental operators affects how people think about and approach problems. If not given an operator, it has more friction to use it, and fewer people will know about it, even though it's a 1 cycle operation on pretty much all hardware, a fact that I think most programmers just forget about since it is not an operator. I personally think an operator, not a builtin, is the appropriate level of at-your-fingertips Zig should provide for such a simple, low-level, and widely supported operation.
|
Im more in favor of the |
Circular shift (or bit rotation) is a common operation to perform and most every architecture out there has hardware support for it. Since we already use the
%
token to qualify existing operators with wraparound behavior, I propose we use>>%
/>>%=
/<<%
/<<%=
to denote circular shift operations.The text was updated successfully, but these errors were encountered: