public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR libstdc++/80506 fix constant used in condition
@ 2017-04-24 14:59 Jonathan Wakely
  2017-04-26  9:19 ` Paolo Carlini
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-24 14:59 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Vincent Poinot, Paolo Carlini

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

We use the wrong constant for the Marsaglia Tsang algorithm.

	PR libstdc++/80506
	* include/bits/random.tcc (gamma_distribution::operator()): Fix magic
	number used in loop condition.

Tested powerpc64le-linux, committed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 873 bytes --]

commit aa4da6523b7bfab7ba92c2e9e505155e1ce432a7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Apr 24 13:10:49 2017 +0100

    PR libstdc++/80506 fix constant used in condition
    
    	PR libstdc++/80506
    	* include/bits/random.tcc (gamma_distribution::operator()): Fix magic
    	number used in loop condition.

diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index df05ebe..63d1c02 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -2356,7 +2356,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    __v = __v * __v * __v;
 	    __u = __aurng();
 	  }
-	while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+	while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 	       && (std::log(__u) > (0.5 * __n * __n + __a1
 				    * (1.0 - __v + std::log(__v)))));
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-07 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 14:59 [PATCH] PR libstdc++/80506 fix constant used in condition Jonathan Wakely
2017-04-26  9:19 ` Paolo Carlini
2017-04-26  9:27   ` Paolo Carlini
2017-04-26  9:33     ` Jonathan Wakely
2018-05-06  1:19       ` Ed Smith-Rowland
2018-05-07 12:22         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).