From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6691 invoked by alias); 24 Jun 2010 09:28:41 -0000 Received: (qmail 6654 invoked by uid 48); 24 Jun 2010 09:28:27 -0000 Date: Thu, 24 Jun 2010 09:28:00 -0000 Subject: [Bug libstdc++/44653] New: A uniform_real random distribution produces invalid floating-point random numbers X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dchichkov at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-06/txt/msg02321.txt.bz2 According to: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1452.html [quote] A uniform_real random distribution produces floating-point random numbers x in the range min <= x <= max, with equal probability. min and max are the parameters of the distribution. [/unqoute] Following code (with either -std=c++0x or -std=gnu++0x): #include #include int main() { std::tr1::mt19937 e; std::tr1::uniform_real dist(0.0, 1.0); std::cout << dist(e) << std::endl; return 0; } Produces: 3.49921e+09. It should produce a value between [0.0, 1.0). Not some wild int. -- Summary: A uniform_real random distribution produces invalid floating-point random numbers Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dchichkov at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44653