From 31197cace95de7fc2fd02b8b9dd0ba3a690db1d5 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 22 May 2026 18:06:26 +0100 Subject: [PATCH] Fix edge case short circuit logic in binomial distro inverse. Fixes: https://github.com/boostorg/math/issues/1397 --- include/boost/math/distributions/binomial.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/math/distributions/binomial.hpp b/include/boost/math/distributions/binomial.hpp index b17893e422..93b148eac8 100644 --- a/include/boost/math/distributions/binomial.hpp +++ b/include/boost/math/distributions/binomial.hpp @@ -226,7 +226,7 @@ namespace boost // but zero is the best we can do: return 0; } - if(p == 1 || success_fraction == 1) + if(q == 0 || success_fraction == 1) { // Probability of n or fewer successes is always one, // so n is the most sensible answer here: return trials;