I was on a pipeline of functions and realised that, when converting integers into floats (not always, but in specific cases!), I lose some units on the way... Let me share an example (you can run it online here):
fn main() {
let int_var:i64 = 12091941575702789;
let converted:f64 = int_var as f64;
println!("NUM: {:.1}", converted);
}
// Prints
NUM: 12091941575702788.0
Is there maybe another way to do this cast? I tried using f64::from(v)
but "the trait From is not implemented for f64".
Thanks in advance!