Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

rust round 2 decimal places

fn main() {
    let x = 12.34567_f64;
    let y = (x * 100.0).round() / 100.0;

    println!("{:.5} {:.5}", x, y);
}

// There is no built in method
 
PREVIOUS NEXT
Tagged: #rust #decimal #places
ADD COMMENT
Topic
Name
3+2 =