From 207d3ef978a1e07d1ab15c64b8bf1633eb152037 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 5 Apr 2022 17:28:34 +0200 Subject: [PATCH] Add abs function --- Utils/MathUtils.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Utils/MathUtils.h b/Utils/MathUtils.h index 18934c2..1aab20a 100644 --- a/Utils/MathUtils.h +++ b/Utils/MathUtils.h @@ -20,6 +20,10 @@ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; }) +#define abs(a) \ + ({ __typeof__ (a) _a = (a); \ + _a > 0 ? _a : -_a; }) + #define deg2rad(angle) \ ({ __typeof__ (angle) _angle = (angle); \ (_angle) * M_PI / 180.0; }) @@ -28,4 +32,4 @@ ({ __typeof__ (angle) _angle = (angle); \ (_angle) * 180.0 / M_PI; }) -#endif \ No newline at end of file +#endif