- Fixed integer pow from GTX_integer with null exponent #658

This commit is contained in:
Christophe Riccio
2017-07-24 11:39:16 +02:00
parent ad744735f6
commit 50a527c97d
4 changed files with 51 additions and 3 deletions

View File

@@ -52,6 +52,47 @@ int test_nlz()
return Error;
}
int test_pow_uint()
{
int Error = 0;
glm::uint const p0 = glm::pow(2u, 0u);
Error += p0 == 1u ? 0 : 1;
glm::uint const p1 = glm::pow(2u, 1u);
Error += p1 == 2u ? 0 : 1;
glm::uint const p2 = glm::pow(2u, 2u);
Error += p2 == 4u ? 0 : 1;
return Error;
}
int test_pow_int()
{
int Error = 0;
int const p0 = glm::pow(2, 0u);
Error += p0 == 1 ? 0 : 1;
int const p1 = glm::pow(2, 1u);
Error += p1 == 2 ? 0 : 1;
int const p2 = glm::pow(2, 2u);
Error += p2 == 4 ? 0 : 1;
int const p0n = glm::pow(-2, 0u);
Error += p0n == -1 ? 0 : 1;
int const p1n = glm::pow(-2, 1u);
Error += p1n == -2 ? 0 : 1;
int const p2n = glm::pow(-2, 2u);
Error += p2n == 4 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -59,6 +100,8 @@ int main()
Error += test_nlz();
// Error += test_floor_log2();
Error += test_log2();
Error += test_pow_uint();
Error += test_pow_int();
return Error;
}