From b81d4986b93d433328c839262f01e12a039136a8 Mon Sep 17 00:00:00 2001 From: willll <464311+willll@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:53:30 -0500 Subject: [PATCH] feat(fxp): add Abs function to compute absolute value of fixed-point numbers --- impl/fxp.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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