Rust Convert Floating Point Number To A String With Decimal

[Solved] Rust Convert Floating Point Number To A String With Decimal | Haskell - Code Explorer | yomemimo.com
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

Answers related to rust convert floating point number to a string with decimal digits

Code Explorer Popular Question For Haskell