diff --git a/src/themachinethatgoesping/tools/.docstrings/helper.doc.hpp b/src/themachinethatgoesping/tools/.docstrings/helper.doc.hpp index ea363df..bce7c2d 100644 --- a/src/themachinethatgoesping/tools/.docstrings/helper.doc.hpp +++ b/src/themachinethatgoesping/tools/.docstrings/helper.doc.hpp @@ -1,4 +1,4 @@ -//sourcehash: 9f2879b584e4bfb300551b9ca3ab8460dcc2c30a83d73fcd28eaa700d25d89e4 +//sourcehash: 8fbf31d3b83d1642941424adcb4a58ae322f9a64011c8fa9efc314f19b215d9d /* This file contains docstrings for use in the Python bindings. @@ -65,6 +65,8 @@ static const char *__doc_themachinethatgoesping_tools_helper_approx_container_co static const char *__doc_themachinethatgoesping_tools_helper_compare_containers = R"doc()doc"; +static const char *__doc_themachinethatgoesping_tools_helper_float_equals = R"doc()doc"; + static const char *__doc_themachinethatgoesping_tools_helper_get_from_map_with_default = R"doc()doc"; static const char *__doc_themachinethatgoesping_tools_helper_int_as_string = R"doc()doc"; diff --git a/src/themachinethatgoesping/tools/helper.hpp b/src/themachinethatgoesping/tools/helper.hpp index 7a9e506..09fd644 100644 --- a/src/themachinethatgoesping/tools/helper.hpp +++ b/src/themachinethatgoesping/tools/helper.hpp @@ -221,6 +221,13 @@ inline bool compare_containers(const t_container1& c1, const t_container2& c2) return false; } +template +bool float_equals(t_float a, t_float b, t_float epsilon = 0.0001) +{ + return std::abs(a - b) < epsilon || (std::isnan(a) && std::isnan(b)) || + (std::isinf(a) && std::isinf(b)); +} + } // namespace helper } // namespace tools } // namespace themachinethatgoesping