From 7e42f3d7c84ed4e4ee1d0fa85394dafa42d5c9e4 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Wed, 31 Aug 2016 03:16:13 +0100 Subject: [PATCH] Allow HMM_PowerF to try and compute negative bases --- HandmadeMath.h | 9 +-------- test/hmm_test.cpp | 2 -- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/HandmadeMath.h b/HandmadeMath.h index 9a5ec40..ad54aa8 100644 --- a/HandmadeMath.h +++ b/HandmadeMath.h @@ -680,14 +680,7 @@ HMM_Power(float Base, int Exponent) HINLINE float HMM_PowerF(float Base, float Exponent) { - if (Base > 0) - { - return expf(Exponent * logf(Base)); - } - else - { - return -expf(Exponent * logf(-Base)); - } + return expf(Exponent * logf(Base)); } HINLINE float diff --git a/test/hmm_test.cpp b/test/hmm_test.cpp index e94f624..a14fb2b 100644 --- a/test/hmm_test.cpp +++ b/test/hmm_test.cpp @@ -61,9 +61,7 @@ TEST(ScalarMath, PowerF) { EXPECT_FLOAT_EQ(HMM_PowerF(2.0f, 0), 1.0f); EXPECT_NEAR(HMM_PowerF(2.0f, 4.1), 17.148376f, 0.0001f); - EXPECT_NEAR(HMM_PowerF(-2.0f, 4.1), -17.148376f, 0.0001f); EXPECT_NEAR(HMM_PowerF(2.0f, -2.5), 0.176777f, 0.0001f); - EXPECT_NEAR(HMM_PowerF(-2.0f, -2.5), -0.176777f, 0.0001f); } TEST(ScalarMath, Lerp)