From efa16b1b9b962e5596be8b8075390551039e0910 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 13 Oct 2023 16:49:39 -0400 Subject: [PATCH] going fancy to allow static_assert --- util/include/rusefi/math.h | 8 ++++++-- util/src/math.cpp | 8 -------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/util/include/rusefi/math.h b/util/include/rusefi/math.h index 183bb1d..acc86e0 100644 --- a/util/include/rusefi/math.h +++ b/util/include/rusefi/math.h @@ -7,8 +7,12 @@ #include // absolute value -int absI(int value); -float absF(float value); +constexpr int absI(int value) { + return value > 0 ? value : -value; + } +constexpr float absF(float value) { + return value > 0 ? value : -value; + } // Min/max int maxI(int i1, int i2); diff --git a/util/src/math.cpp b/util/src/math.cpp index 2932c68..a184007 100644 --- a/util/src/math.cpp +++ b/util/src/math.cpp @@ -2,14 +2,6 @@ #include -float absF(float value) { - return value > 0 ? value : -value; -} - -int absI(int value) { - return value >= 0 ? value : -value; -} - int maxI(int i1, int i2) { return i1 > i2 ? i1 : i2; }