Created
February 17, 2019 16:59
-
-
Save jafow/79ee99a4cfccb3e33baab8b1f62eee10 to your computer and use it in GitHub Desktop.
1s complement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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