Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/random_lcg.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "openmc/random_lcg.h"

#include <cmath>

namespace openmc {

// Starting seed
Expand Down Expand Up @@ -78,8 +76,9 @@ double prn(uint64_t* seed)
((*seed >> ((*seed >> 59u) + 5u)) ^ *seed) * 12605985483714917081ull;
uint64_t result = (word >> 43u) ^ word;

// Convert output from unsigned integer to double
return ldexp(result, -64);
// Convert output from unsigned integer to double. Multiplying by an exact
// power of two gives the same result as ldexp but avoids a library call.
return static_cast<double>(result) * 0x1p-64;
}

//==============================================================================
Expand Down
Loading