forked from asklyphe-public/asklyphe
Fix them rounding errors!
This commit is contained in:
parent
86c6c96909
commit
b101b5af51
1 changed files with 4 additions and 3 deletions
|
@ -22,11 +22,12 @@ pub fn calculate(query: &str) -> Option<Calculation> {
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue