Use the right upper bound for the exponent.

This commit is contained in:
Steven Watanabe 2014-04-12 08:40:25 -07:00
parent dc7f3ec6f7
commit a8aed49f29
3 changed files with 17 additions and 1 deletions

View File

@ -257,7 +257,7 @@ public:
std::fill_n(out + 1, n - 1, digit_t(0));
return;
}
boost::uintmax_t i = bits - 1;
boost::uintmax_t i = std::numeric_limits<boost::uintmax_t>::digits - 1;
while(((boost::uintmax_t(1) << i) & exponent) == 0) {
--i;
}

View File

@ -182,6 +182,21 @@ BOOST_AUTO_TEST_CASE(test_discard2)
}
#endif
#ifdef BOOST_RANDOM_DISCARD_MAX
BOOST_AUTO_TEST_CASE(test_discard_max)
{
boost::uintmax_t val = (std::numeric_limits<boost::uintmax_t>::max)();
boost::uintmax_t half = val / 2;
BOOST_RANDOM_URNG urng;
BOOST_RANDOM_URNG urng2;
urng.discard(half);
urng.discard(half);
urng.discard(val - 2*half);
urng2.discard(val);
BOOST_CHECK_EQUAL(urng, urng2);
}
#endif
BOOST_AUTO_TEST_CASE(test_copy)
{
BOOST_RANDOM_URNG urng;

View File

@ -24,6 +24,7 @@
#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3408548740U
#define BOOST_RANDOM_DISCARD_COUNT1 9307
#define BOOST_RANDOM_DISCARD_COUNT2 20000000
#define BOOST_RANDOM_DISCARD_MAX
#define BOOST_RANDOM_GENERATE_VALUES { 0xD091BB5CU, 0x22AE9EF6U, 0xE7E1FAEEU, 0xD5C31F79U }