Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70761 - trunk/boost/random/detail
From: steven_at_[hidden]
Date: 2011-03-30 16:41:50


Author: steven_watanabe
Date: 2011-03-30 16:41:50 EDT (Wed, 30 Mar 2011)
New Revision: 70761
URL: http://svn.boost.org/trac/boost/changeset/70761

Log:
Use fmod before casting to uint32_t. xlc and sun were saturating to 0xFFFFFFFF instead of taking the low order bits.
Text files modified:
   trunk/boost/random/detail/seed_impl.hpp | 5 +++--
   1 files changed, 3 insertions(+), 2 deletions(-)

Modified: trunk/boost/random/detail/seed_impl.hpp
==============================================================================
--- trunk/boost/random/detail/seed_impl.hpp (original)
+++ trunk/boost/random/detail/seed_impl.hpp 2011-03-30 16:41:50 EDT (Wed, 30 Mar 2011)
@@ -85,6 +85,7 @@
 template<class Engine, class Iter>
 void generate_from_real(Engine& eng, Iter begin, Iter end)
 {
+ using std::fmod;
     typedef typename Engine::result_type RealType;
     const int Bits = Engine::precision();
     int remaining_bits = 0;
@@ -106,7 +107,7 @@
             if(Bits < 32 || remaining_bits != 0) {
                 boost::uint_least32_t divisor =
                     (boost::uint_least32_t(1) << (32 - remaining_bits));
- boost::uint_least32_t extra_bits = boost::uint_least32_t(val) & (divisor - 1);
+ boost::uint_least32_t extra_bits = boost::uint_least32_t(fmod(val, mult32)) & (divisor - 1);
                 val = val / divisor;
                 *begin++ = saved_bits | (extra_bits << remaining_bits);
                 if(begin == end) return;
@@ -116,7 +117,7 @@
             // If Bits < 32 we should never enter this loop
             if(Bits >= 32) {
                 for(; available_bits >= 32; available_bits -= 32) {
- boost::uint_least32_t word = boost::uint_least32_t(val);
+ boost::uint_least32_t word = boost::uint_least32_t(fmod(val, mult32));
                     val /= mult32;
                     *begin++ = word;
                     if(begin == end) return;


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