How to do it...

  1. Enter the following code in a Rust script named decimal.rs and compile them:
        fn main(){

// Prints the first 2 numbers after the decimal points
println!("{:.2}",1.2345 );
println!("================");

// print the binary hex and octal format
println!("B: {:b} H: {:x} O: {:o}",10,10,10 );
println!("================");

// Shifts
println!("{ten:>ws$}",ten=10, ws=5 );
println!("{ten:>0ws$}",ten=10, ws=5 );
}

2. The output of the code is as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.97.202