summaryrefslogtreecommitdiff
path: root/libcxx/include/random
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /libcxx/include/random
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
Diffstat (limited to 'libcxx/include/random')
-rw-r--r--libcxx/include/random5
1 files changed, 5 insertions, 0 deletions
diff --git a/libcxx/include/random b/libcxx/include/random
index 7c4054f7eea8..ce3d135e064a 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -4048,10 +4048,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
result_type __rd = __ru;
while (true)
{
+ bool __break = true;
if (__rd >= 1)
{
__pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1));
__u -= __pd;
+ __break = false;
if (__u < 0)
return __rd - 1;
}
@@ -4062,9 +4064,12 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
{
__pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru;
__u -= __pu;
+ __break = false;
if (__u < 0)
return __ru;
}
+ if (__break)
+ return 0;
}
}