-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
wrapping negation -% should work on unsigned ints #1770
Comments
I'm not convinced. Everywhere else in Zig, operations such as negation refer to the mathematical meaning, not a bitwise interpretation. Negation of an unsigned integer does not make sense mathematically. The I will re-open this issue if a counter-argument is provided. |
|
OK, when you put it that way, it makes sense, and I agree. |
This is used in C in these algorithms: http://www.pcg-random.org/posts/bounded-rands.html (search for "-range").
Semantics:
I'm trying to port this code to Zig, and the workarounds with
@bitCast
or~
obscure the origin and intent of the code.The text was updated successfully, but these errors were encountered: