2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-26 18:52:10 +00:00

Fix binomial_coefficient forwarding policy

This addresses an issue where unintended double-promotion could occur.

See #398.
This commit is contained in:
Evan Miller
2020-07-10 07:08:07 -04:00
parent 5206b25e96
commit 9869e7a515

View File

@@ -63,7 +63,13 @@ T binomial_coefficient(unsigned n, unsigned k, const Policy& pol)
template <>
inline float binomial_coefficient<float, policies::policy<> >(unsigned n, unsigned k, const policies::policy<>& pol)
{
return policies::checked_narrowing_cast<float, policies::policy<> >(binomial_coefficient<double>(n, k, pol), "boost::math::binomial_coefficient<%1%>(unsigned,unsigned)");
typedef policies::normalise<
policies::policy<>,
policies::promote_float<true>,
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
return policies::checked_narrowing_cast<float, forwarding_policy>(binomial_coefficient<double>(n, k, forwarding_policy()), "boost::math::binomial_coefficient<%1%>(unsigned,unsigned)");
}
template <class T>