This commit is contained in:
Simon Gardling
2022-02-23 15:37:49 -05:00
parent 59e4793a1b
commit e049038813
4 changed files with 28 additions and 7 deletions

View File

@@ -107,6 +107,12 @@ pub fn test_func(function_string: String) -> String {
"".to_string()
}
// Rounds f64 to specific number of digits
pub fn digits_precision(x: f64, digits: usize) -> f64 {
let large_number: f64 = (10.0 as f64).powf(digits as f64);
(x * large_number).round() / large_number
}
pub struct Function {
function: Box<dyn Fn(f64) -> f64>,
func_str: String,