mirror of
https://github.com/HandmadeMath/HandmadeMath.git
synced 2026-08-28 23:21:30 +00:00
Allow HMM_PowerF to try and compute negative bases
This commit is contained in:
@@ -680,14 +680,7 @@ HMM_Power(float Base, int Exponent)
|
|||||||
HINLINE float
|
HINLINE float
|
||||||
HMM_PowerF(float Base, float Exponent)
|
HMM_PowerF(float Base, float Exponent)
|
||||||
{
|
{
|
||||||
if (Base > 0)
|
return expf(Exponent * logf(Base));
|
||||||
{
|
|
||||||
return expf(Exponent * logf(Base));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -expf(Exponent * logf(-Base));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HINLINE float
|
HINLINE float
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ TEST(ScalarMath, PowerF)
|
|||||||
{
|
{
|
||||||
EXPECT_FLOAT_EQ(HMM_PowerF(2.0f, 0), 1.0f);
|
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, 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);
|
||||||
EXPECT_NEAR(HMM_PowerF(-2.0f, -2.5), -0.176777f, 0.0001f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ScalarMath, Lerp)
|
TEST(ScalarMath, Lerp)
|
||||||
|
|||||||
Reference in New Issue
Block a user