Answers for "rust float from int"

1

how to add integer and float in rust

fn main(){
    let x:f32=20.0;        
    let y:i32=10;
    let sum = x + y as f32;
    println!("{}",sum);
}
Posted by: Guest on August-30-2021
0

string from float rust

let pi = 3.1415926;
let s = pi.to_string();  // : String
Posted by: Guest on July-13-2021

Browse Popular Code Answers by Language