Skip to content

Commit

Permalink
Merge pull request #5746 from n8sh/xorshift-fix
Browse files Browse the repository at this point in the history
Fix Issue 17862 - std.random.XorshiftEngine.min is wrong when bits == 32
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Mar 23, 2018
2 parents 4e09914 + fa92151 commit cc256d8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion std/random.d
Expand Up @@ -1027,7 +1027,7 @@ if (isUnsigned!UIntType)
/// Always $(D false) (random generators are infinite ranges).
enum empty = false;
/// Smallest generated value.
enum UIntType min = 0;
enum UIntType min = seeds_.length == 1 ? 1 : 0;
/// Largest generated value.
enum UIntType max = UIntType.max;

Expand Down Expand Up @@ -1234,6 +1234,8 @@ alias Xorshift = Xorshift128; /// ditto
static assert(isSeedable!Xorshift);
static assert(isSeedable!(Xorshift, uint));

static assert(Xorshift32.min == 1);

// Result from reference implementation.
auto checking = [
[2463534242UL, 901999875, 3371835698, 2675058524, 1053936272, 3811264849,
Expand Down

0 comments on commit cc256d8

Please sign in to comment.