Op 15 mrt. 2012 03:31 schreef "K. Frank" <[email protected]> het
volgende:
>
> Hello Jim and Kai and Ruben and Friends!
>
> I see something similar to Jim's bug in <tr1/random>, but
> not in <random>.
>
> On Wed, Mar 14, 2012 at 2:22 AM, Jim Michaels <[email protected]> wrote:
> > /*
> > Author: Jim Michaels
> > ...
> > #include <tr1/random>
> > ...
> > //problem: this hovers way too long around
> > /*
> > sample output:
> > 18446744072913795932
> > 18446744073304931054
> > 18446744073000918905
> > 18446744073575839711
> > 18446744073337503749
> > ...
>
> First, Jim's observation does look like a bug to me.  I don't see anything
> in his code that looks wrong (but I often overlook things).
>
> Also, when I run a similar test program, I see a similar problem when I
> use <tr1/random>:
>
>   00000000003499211612
>   00000000000581869302
>   00000000003890346734
>   00000000003586334585
>   00000000000545404204
>
>  but not when I use <random>.
>
>   15028999435905310454
>   16708911996216745849
>   02342493223442167775
>   16848810653347327969
>   11664969248402573611
>
> (One speculation on the difference between Jim's bug observation
> and mine:  Maybe the high-order word isn't getting set by uniform_int,
> and for some reason Jim is getting garbage in the high-order word,
> while I am getting zero.)
>
> My complete program and output follow, below.
>
> Note, I am using one of Ruben's std::thread-enabled 4.7.0 64-bit
> builds.
>
> I suppose that there is a bug, but if I'm right that it's only in
> <tr1/random>, I'm not sure how much we care.  Maybe the
> bug fix should be to junk tr1.  I don't have much appetite for
> investigating tr1 any further as c++11's <random> seems to
> be working correctly in this regard.

If the real <random> header does work correctly, this is indeed also my
stance on the subject. Tr1 is old, c++11's real headers, which are
available everywhere you could wish for, replace and improve every bit of
functionality provided by tr1. Stop using tr1.

Thanks for the test,

Ruben

>
> > ...
> > Jim Michaels
> > ...
>
> Thanks for bringing this up, and Happy Hacking!
>
> K. Frank
>
> --- program details ---
>
> C:\random_test>type uniform_test.cpp
> #include <iostream>
> #include <random>
> #include <tr1/random>
>
> int main () {
>  std::cout << "<random>..." << std::endl;
>  std::mt19937 mte;
>  std::uniform_int_distribution<unsigned long long> ull_dist {0ULL,
> 0xffffffffffffffffULL};
>
>  for (unsigned i = 0; i < 10; i++) {
>    std::cout.fill('0');
>    std::cout.width(20);
>    std::cout << ull_dist (mte) << std::endl;
>  }
>
>  std::cout << "<tr1/random>..." << std::endl;
>  std::tr1::mt19937 mte2;
>  std::tr1::uniform_int<unsigned long long> ull_dist2 {0ULL,
> 0xffffffffffffffffULL};
>
>  for (unsigned i = 0; i < 10; i++) {
>    std::cout.fill('0');
>    std::cout.width(20);
>    std::cout << ull_dist2 (mte2) << std::endl;
>  }
>
>  return 0;
> }
>
> C:\random_test>g++ --version
> g++ (GCC) 4.7.0 20110829 (experimental)
> Copyright (C) 2011 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
>
>
> C:\random_test>g++ -std=c++0x -o uniform_test uniform_test.cpp
>
> C:\random_test>uniform_test
> <random>...
> 15028999435905310454
> 16708911996216745849
> 02342493223442167775
> 16848810653347327969
> 11664969248402573611
> 01799302827895858725
> 05137385360522333466
> 10088183424363624464
> 17662883439475955428
> 17799051847008967418
> <tr1/random>...
> 00000000003499211612
> 00000000000581869302
> 00000000003890346734
> 00000000003586334585
> 00000000000545404204
> 00000000004161255391
> 00000000003922919429
> 00000000000949333985
> 00000000002715962298
> 00000000001323567403
>
> C:\random_test>
>
>
------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to