[Issue 2882] New: std.random.MersenneTwisterEngine without no seed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 22 16:22:42 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2882

           Summary: std.random.MersenneTwisterEngine without no seed
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P4
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: repeatedly at gmail.com


void main()
{
    writeln("Case1");
    {
        Mt19937 gen = Mt19937(0);
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("---");
    {
        Mt19937 gen = Mt19937(0);
        advance(gen, 1);  // skip 1 element
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("Â¥nCase2");
    {
        Mt19937 gen;
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
    writeln("---");
    {
        Mt19937 gen;
        advance(gen, 1);  // skip 1 element
        writeln(gen.front);
        gen.popFront;
        writeln(gen.front);
    }
}

Result:

Case1
2357136044 (1)
2546248239 (2)
---
2546248239 (2)
3071714933 (3)

Case2
581869302  (1)
3890346734 (2)
---
581869302  (1)?
3890346734 (2)?

The second part of Case2 skipped one element using advance(calling popFront),
but the result didn't skip.


-- 



More information about the Digitalmars-d-bugs mailing list