diff --git a/asklyphe-frontend/src/math.rs b/asklyphe-frontend/src/math.rs index d3ea75f..860fcaa 100644 --- a/asklyphe-frontend/src/math.rs +++ b/asklyphe-frontend/src/math.rs @@ -22,11 +22,12 @@ pub fn calculate(query: &str) -> Option { let mut parser = Parser::new(Lexer::new(query)); let mut tree = parser.parse()?; let res = tree.eval(); + let res_float = f64::from_str(&format!("{}", res)).unwrap(); debug!("Calculation: {}", query); - // debug!("Tree: {:?}", tree); - debug!("Result: {}", res); - Some(Calculation {equation: query.to_string(), result: res.to_string()}) + debug!("Tree: {:?}", tree); + debug!("Result: {:?}", res_float); + Some(Calculation {equation: query.to_string(), result: res_float.to_string()}) } // TODO: put into own crate with dependency astro-float = "0.9.2" so I can use more than BigFloat