Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/random/binomial_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class binomial_distribution {
IntType k = static_cast<IntType>(floor((2*_u.btrd.a/us + _u.btrd.b)*u + _u.btrd.c));
if(k < 0 || k > _t) continue;
v = v*_u.btrd.alpha/(_u.btrd.a/(us*us) + _u.btrd.b);
RealType km = abs(k - m);
RealType km = abs(static_cast<RealType>(k) - static_cast<RealType>(m));
if(km <= 15) {
RealType f = 1;
if(m < k) {
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ run test_comp_xoshiro128f.cpp ;

run github_issue_133.cpp ;
run github_issue_147.cpp ;
run github_issue_150.cpp ;

run niederreiter_base2_validate.cpp /boost/test//boost_unit_test_framework ;
run sobol_validate.cpp /boost/test//boost_unit_test_framework ;
Expand Down
25 changes: 25 additions & 0 deletions test/github_issue_150.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Matt Borland 2025.
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id$
*/

#include <boost/random.hpp>
#include <boost/core/lightweight_test.hpp>
#include <random>
#include <cstdint>

int main()
{
std::mt19937_64 gen;
boost::random::binomial_distribution<std::uint64_t> dist;

BOOST_TEST(dist(gen) >= 0);

return boost::report_errors();
}
Loading