Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63155 - trunk/boost/random
From: steven_at_[hidden]
Date: 2010-06-20 15:06:57


Author: steven_watanabe
Date: 2010-06-20 15:06:56 EDT (Sun, 20 Jun 2010)
New Revision: 63155
URL: http://svn.boost.org/trac/boost/changeset/63155

Log:
Fix another integer overflow problem.
Text files modified:
   trunk/boost/random/binomial_distribution.hpp | 7 ++++++-
   1 files changed, 6 insertions(+), 1 deletions(-)

Modified: trunk/boost/random/binomial_distribution.hpp
==============================================================================
--- trunk/boost/random/binomial_distribution.hpp (original)
+++ trunk/boost/random/binomial_distribution.hpp 2010-06-20 15:06:56 EDT (Sun, 20 Jun 2010)
@@ -253,7 +253,12 @@
     static RealType fc(IntType k)
     {
         if(k < 10) return detail::binomial_table<RealType>::table[k];
- else return (1./12 - (1./360 - 1./1260/((k+1)*(k+1)))/((k+1)*(k+1)))/(k+1);
+ else {
+ RealType ikp1 = RealType(1) / (k + 1);
+ return (RealType(1)/12
+ - (RealType(1)/360
+ - (RealType(1)/1260)*(ikp1*ikp1))*(ikp1*ikp1))*ikp1;
+ }
     }
 
     void init()


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk