changes from my egui fork

This commit is contained in:
Simon Gardling
2022-05-13 14:13:19 -04:00
parent 2d63c1b5f7
commit e2c2713633
6 changed files with 43 additions and 35 deletions

View File

@@ -531,7 +531,7 @@ impl FunctionEntry {
}
// return value rounded to 8 decimal places
Some(crate::misc::decimal_round(integral_data.1, 8))
Some(emath::round_to_decimals(integral_data.1, 8))
}
_ => None,
}

View File

@@ -28,8 +28,14 @@ pub use crate::{
function_entry::{FunctionEntry, Riemann},
math_app::AppSettings,
misc::{
decimal_round, format_bytes, hashed_storage_create, hashed_storage_read,
option_vec_printer, resolution_helper, step_helper, SteppedVector,
// decimal_round,
format_bytes,
hashed_storage_create,
hashed_storage_read,
option_vec_printer,
resolution_helper,
step_helper,
SteppedVector,
},
};

View File

@@ -188,13 +188,13 @@ impl EguiHelper for Vec<Value> {
fn to_tuple(&self) -> Vec<(f64, f64)> { self.iter().map(|ele| (ele.x, ele.y)).collect() }
}
/// Rounds f64 to `n` decimal places
pub fn decimal_round(x: f64, n: usize) -> f64 {
let large_number: f64 = 10.0_f64.powf(n as f64); // 10^n
// /// Rounds f64 to `n` decimal places
// pub fn decimal_round(x: f64, n: usize) -> f64 {
// let large_number: f64 = 10.0_f64.powf(n as f64); // 10^n
// round and devide in order to cutoff after the `n`th decimal place
(x * large_number).round() / large_number
}
// // round and devide in order to cutoff after the `n`th decimal place
// (x * large_number).round() / large_number
// }
/// Helper that assists with using newton's method of finding roots, iterating over data `data`
/// `threshold` is the target accuracy threshold