Skip to content

Commit

Permalink
Fix i386 bug
Browse files Browse the repository at this point in the history
Use std::log2(x) instead of std::log(x)/std::log(2.0) for improved accuracy.
  • Loading branch information
kimwalisch committed Nov 12, 2017
1 parent a1d3a3b commit 6c74531
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/floorPow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void check(bool OK)

uint64_t floorPow2_cmath(uint64_t n)
{
return 1ull << (uint64_t) (log((double) n) / log(2.0));
return 1ull << (uint64_t) log2(n);
}

int main()
Expand Down

0 comments on commit 6c74531

Please sign in to comment.