Skip to content

Instantly share code, notes, and snippets.

@jafow
Created February 17, 2019 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jafow/79ee99a4cfccb3e33baab8b1f62eee10 to your computer and use it in GitHub Desktop.
Save jafow/79ee99a4cfccb3e33baab8b1f62eee10 to your computer and use it in GitHub Desktop.
1s complement
fn main() {
// bitwise complement of unsigned int
let bw: u32 = 1;
let nbw = !bw;
assert_eq!(nbw, 4294967294);
// bitwise complement of signed int
let bw: i32 = 1;
let nbw = !bw;
assert_eq!(nbw, -2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment