15 #include "absl/random/internal/fastmath.h"
17 #include "gtest/gtest.h"
19 #if defined(__native_client__) || defined(__EMSCRIPTEN__)
25 #define ABSL_RANDOM_INACCURATE_LOG2
30 TEST(FastMathTest, IntLog2FloorTest) {
43 for (
int i = 0;
i < 64;
i++) {
46 EXPECT_EQ(
i,
static_cast<int>(std::log2(i_pow_2)));
49 for (
int j =
i - 1;
j > 0; --
j) {
50 y =
y | (i_pow_2 >>
j);
56 TEST(FastMathTest, IntLog2CeilTest) {
69 for (
int i = 0;
i < 64;
i++) {
72 #ifndef ABSL_RANDOM_INACCURATE_LOG2
73 EXPECT_EQ(
i,
static_cast<int>(std::ceil(std::log2(i_pow_2))));
77 for (
int j =
i - 1;
j > 0; --
j) {
78 y =
y | (i_pow_2 >>
j);
91 for (
int i = 2;
i < 50;
i++) {
92 double d =
static_cast<double>(
i);