Question : rust convert a string (with decimals) to a floating point number.
Answered by : mackerel
let f = s.parse::<f32>().unwrap();
// Can also do:
let f: f32 = s.parse().unwrap();
Source : | Last Update : Wed, 03 Mar 21
Question : rust convert floating point number, to a string, with decimal digits.
Answered by : mackerel
let s = format!("{:.2}", x);
Source : | Last Update : Wed, 03 Mar 21