On 04/26/2017 05:16 AM, Jonathan Wakely wrote:
On 26/04/17 11:14 +0200, Paolo Carlini wrote:
.. or maybe using the wrong constant only impacts the performance?!?

Yes, I think so. I did some very simple sanity tests and the numbers
were identical before and after.



I was backporting this and saw that __generate_impl does this twice more.

For trunk and branch-8 I have these patches.

OK?


2018-05-07  Edward Smith-Rowland  <3dw...@verizon.net>

        Moar PR libstdc++/80506
        * include/bits/random.tcc (gamma_distribution::__generate_impl()):
        Fix magic number used in loop condition.
Index: include/bits/random.tcc
===================================================================
--- include/bits/random.tcc     (revision 259965)
+++ include/bits/random.tcc     (working copy)
@@ -2408,7 +2408,7 @@
                  __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)))));
 
@@ -2429,7 +2429,7 @@
                  __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)))));
 

Reply via email to