Allow HMM_PowerF to try and compute negative bases

This commit is contained in:
Matt Mascarenhas
2016-08-31 03:16:13 +01:00
parent fcc3052ed4
commit 7e42f3d7c8
2 changed files with 1 additions and 10 deletions

View File

@@ -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

View File

@@ -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)