Skip to content

Commit

Permalink
constexpr for division in RNG
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Aug 25, 2024
1 parent 7bd3903 commit 7ef2bd2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/common/rdrandwrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ class RdRandom {

real1_f Next()
{
unsigned v = NextRaw();
real1_f res = ZERO_R1_F;
#if FPPOW < 6
real1_f part = ONE_R1_F / (1ULL << 32U);
constexpr real1_f inc = ONE_R1_F / (1ULL << 32U);
#else
real1_f part = ONE_R1_F / (1ULL << 64U);
constexpr real1_f inc = ONE_R1_F / (1ULL << 64U);
#endif

unsigned v = NextRaw();
real1_f res = ZERO_R1_F;
real1_f part = inc;
for (unsigned i = 0U; i < 32U; ++i) {
if ((v >> i) & 1U) {
res += part;
Expand Down

0 comments on commit 7ef2bd2

Please sign in to comment.