Boost C++ Libraries: Ticket #10241: Please relax template constraints of boost::math::binomial_coefficient https://svn.boost.org/trac10/ticket/10241 <p> boost::math::binomial_coefficient may up to now only be used with floating point types. See also ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3100" title="#3100: Bugs: boost::math::binomial_coefficient causes Aborted (core dumped) (closed: wontfix)">#3100</a>. </p> <p> This constraint has two problems: </p> <p> It yields in inaccurate calculations, i. e. </p> <pre class="wiki">static_cast&lt;long long unsigned&gt;(boost::math::binomial_coefficient&lt;double&gt;(60, 30)); </pre><p> is 118264581564861408 but should be 118264581564861424. (long long unsigned and double are both 8 byte on my machine.) </p> <p> And it does not make sense for very large or arbitrary-precision integer types: boost::math::binomial_coefficient&lt;boost::multiprecision::cpp_int&gt; would work great if you let it do so. </p> <p> At the moment it is not possible just to release integer types as template argument, you have to add an extra implementation, i. e. this one with unsigned k and n as input: </p> <pre class="wiki">Inttype result = 1; k = std::min(k, n-k); for (unsigned i = 1; i &lt; k+1; ++i) { result *= Inttype(n-k+i); result /= Inttype(i); } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10241 Trac 1.4.3