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

unexpected results from bitwise complement operator ! #3229

Open
nobel-sh opened this issue Oct 28, 2024 · 1 comment
Open

unexpected results from bitwise complement operator ! #3229

nobel-sh opened this issue Oct 28, 2024 · 1 comment

Comments

@nobel-sh
Copy link
Contributor

The ! operator produces unexpected results.

fn main(){
   let a: i32 = 5;
   let b = !a; // expected -6 gccrs gives 0.
}

Godbolt: https://godbolt.org/z/cKPPz1bYc

@nobel-sh
Copy link
Contributor Author

I'm not entirely sure, but it seems that the operator is interpreting the least significant bit of the number as a boolean value and complementing it.

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

No branches or pull requests

1 participant