Move approximate equality test for floats to util

This commit is contained in:
Dennis 2024-06-05 12:04:26 +02:00
parent beaaa597d4
commit 995eaec555
No known key found for this signature in database
GPG Key ID: 6937EAEA33A3FA5D
3 changed files with 8 additions and 2 deletions

View File

@ -0,0 +1,4 @@
pub fn approx_equal(a: f64, b: f64, dp: u8) -> bool {
let p = 10f64.powi(-(dp as i32));
(a - b).abs() < p
}

View File

@ -1,4 +1,5 @@
pub mod cli_arguments;
pub mod f64_utils;
pub mod file_util;
pub mod hash_util;
pub mod lexicographic_file_walker;

View File

@ -5,8 +5,9 @@ mod common;
use cheap_ruler::CheapRuler;
use clap::Parser;
use common::{
cli_arguments::Args, hash_util::md5_of_osrm_executables, nearest_response::NearestResponse,
osm::OSMWay, osrm_world::OSRMWorld, task_starter::TaskStarter,
cli_arguments::Args, f64_utils::approx_equal, hash_util::md5_of_osrm_executables,
nearest_response::NearestResponse, osm::OSMWay, osrm_world::OSRMWorld,
task_starter::TaskStarter,
};
use core::panic;
use cucumber::{self, gherkin::Step, given, when, World};