Add helper functions for approximate numerical comparisons
Description
It is often useful to perform approximate numerical comparisons, especially between floating point values. To improve code readability, it would be nice if there were helper functions for doing various types of approximate comparisons.
Expected behavior
Rather than writing checks like this:
if (std::abs(val1 - val2) <= EPS) {
// Do something if val1 ~= val2
}
Write something like this:
if (approx_eq(val1, val2, EPS)) {
// Do something if val1 ~= val2
}
Definition of Done
-
Add code library -
Add library design documentation
Edited by Jeffrey Kane Johnson