optimizations #161

Open
emma wants to merge 44 commits from optimizations into main
Showing only changes of commit 62ce288524 - Show all commits

View File

@ -129,10 +129,6 @@ impl StrError for EvaluationError {
}
}
/* Im no math nerd but I want the highest possible approximation of 0.9
* repeating and it seems this can give it to me */
const PRECISION_MOD: f64 = 0.9 + f64::EPSILON;
fn err<T: StrError>(argv0: &String, e: &T, code: Option<u8>) -> ExitCode {
eprintln!("{}: {}", argv0, e.strerror());
ExitCode::from(code.unwrap_or(1 /* unknown error */))
@ -211,9 +207,9 @@ fn eval(
fn round_precise(value: &f64) -> f64 {
/* Set floating-point precision for correcting rounding errors based on
* machine epsilon */
let precision = (-f64::EPSILON.log10() * PRECISION_MOD).ceil() as i32;
let multiplier = 10_f64.powi(precision as i32);
let precision = (-f64::EPSILON.log10()).floor() as i32;
let multiplier = 10_f64.powi(precision);
(value * multiplier).round() / multiplier
}