diff --git a/libraries/AP_Math/AP_Math.h b/libraries/AP_Math/AP_Math.h index 7d85826f5e..01d47838fe 100644 --- a/libraries/AP_Math/AP_Math.h +++ b/libraries/AP_Math/AP_Math.h @@ -27,9 +27,15 @@ AP_PARAMDEFV(Vector3f, Vector3f, AP_PARAM_VECTOR3F); template bool is_equal(const FloatOne, const FloatTwo); -// is a float is zero -static inline bool is_zero(const float fVal1) { return fabsf(fVal1) < FLT_EPSILON ? true : false; } - +/* + * @brief: Check whether a float is zero + */ +template +inline bool is_zero(const T fVal1) { + static_assert(std::is_floating_point::value || std::is_base_of::value, + "Template parameter not of type float"); + return fabsf(fVal1) < std::numeric_limits::epsilon() ? true : false; +} /* * A variant of asin() that checks the input ranges and ensures a valid angle