[Bug libstdc++/43660] range of random-number generator seems wrong/confusing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43660 --- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org --- (In reply to Jonathan Wakely from comment #2) (In reply to comment #0) [Note that the same issue exists with other ways of invoking using the generator (e.g., a std::uniform_real_distributionfloat with bounds of 0 and 1 will indeed return 1); but it's less clear its a bug in those cases (although, for instance, boost's random implementation never seems to return the upper bound).] Again, referring to the latest draft: A uniform_real_distribution random number distribution produces random numbers x, a = x b So that does appear to be a bug PR 64351 deals with that case.
[Bug libstdc++/43660] range of random-number generator seems wrong/confusing
--- Comment #1 from redi at gcc dot gnu dot org 2010-04-06 10:38 --- n1933 is ancient history, the RNG pieces have changed significantly In the current draft it says: A uniform_int_distribution random number distribution produces random integers i, a = i = b So it is a closed interval [a,b] rather than [a,b) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43660
[Bug libstdc++/43660] range of random-number generator seems wrong/confusing
--- Comment #2 from redi at gcc dot gnu dot org 2010-04-06 10:40 --- (In reply to comment #0) [Note that the same issue exists with other ways of invoking using the generator (e.g., a std::uniform_real_distributionfloat with bounds of 0 and 1 will indeed return 1); but it's less clear its a bug in those cases (although, for instance, boost's random implementation never seems to return the upper bound).] Again, referring to the latest draft: A uniform_real_distribution random number distribution produces random numbers x, a = x b So that does appear to be a bug -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43660
[Bug libstdc++/43660] range of random-number generator seems wrong/confusing
--- Comment #3 from redi at gcc dot gnu dot org 2010-04-06 10:53 --- (In reply to comment #0) As best as I can tell, std::random_shuffle wants its random-number generating functor to return results in the range [0,N), where N is the parameter it passes to the functor; i.e., the upper-bound is exclusive (and the lower-bound inclusive). http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3056.pdf changes the third random_shuffle overload to shuffle and changes the requirements -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43660
[Bug libstdc++/43660] range of random-number generator seems wrong/confusing
--- Comment #4 from paolo dot carlini at oracle dot com 2010-04-06 11:00 --- Jon is right and recently I removed that old comment from random.h because indeed was incorrect. -- paolo dot carlini at oracle dot com changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43660