print number as binary in rust
To print a number as binary in Rust, you can use the format!
macro with the {:b}
format specifier. Here's an example:
fn main() {
let number = 42;
println!("{:b}", number);
}
This will output the binary representation of the number 42
, which is 101010
.