diff --git a/impl/fxp.hpp b/impl/fxp.hpp index b9a1af0..5071c9e 100644 --- a/impl/fxp.hpp +++ b/impl/fxp.hpp @@ -228,6 +228,16 @@ namespace SaturnMath::Types return (a < b) ? a : b; } + /** + * @brief Returns the absolute value of a fixed-point value. + * @param v Input value + * @return |v| + */ + static constexpr Fxp Abs(const Fxp& v) + { + return (v < 0) ? -v : v; + } + /** * @brief Creates fixed-point from raw 16.16 value. * @param rawValue Raw fixed-point bits