From cfec8308a39ae4a2a1a1b1fe0df0a099470d9c78 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 17 Oct 2024 02:58:16 +0100 Subject: Simple constexpr pow function --- lib/maths.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/maths.cpp') diff --git a/lib/maths.cpp b/lib/maths.cpp index ea245f0..f527881 100644 --- a/lib/maths.cpp +++ b/lib/maths.cpp @@ -116,6 +116,18 @@ normalize(float ang) return ang; } +static_assert(pow(1, 0) == 1); +static_assert(pow(1, 1) == 1); +static_assert(pow(1, 2) == 1); +static_assert(pow(2, 0) == 1); +static_assert(pow(2, 1) == 2); +static_assert(pow(2, 2) == 4); +static_assert(pow(2, 3) == 8); +static_assert(pow(3, 0) == 1); +static_assert(pow(3, 1) == 3); +static_assert(pow(3, 2) == 9); +static_assert(pow(pi, 3) == 31.006278991699219F); + float operator"" _mph(const long double v) { -- cgit v1.2.3