comparison DEPENDENCIES/generic/include/boost/random/detail/large_arithmetic.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
5 * accompanying file LICENSE_1_0.txt or copy at 5 * accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt) 6 * http://www.boost.org/LICENSE_1_0.txt)
7 * 7 *
8 * See http://www.boost.org for most recent version including documentation. 8 * See http://www.boost.org for most recent version including documentation.
9 * 9 *
10 * $Id: large_arithmetic.hpp 71018 2011-04-05 21:27:52Z steven_watanabe $ 10 * $Id$
11 */ 11 */
12 12
13 #ifndef BOOST_RANDOM_DETAIL_LARGE_ARITHMETIC_HPP 13 #ifndef BOOST_RANDOM_DETAIL_LARGE_ARITHMETIC_HPP
14 #define BOOST_RANDOM_DETAIL_LARGE_ARITHMETIC_HPP 14 #define BOOST_RANDOM_DETAIL_LARGE_ARITHMETIC_HPP
15 15
29 boost::uintmax_t remainder; 29 boost::uintmax_t remainder;
30 }; 30 };
31 31
32 inline div_t muldivmod(boost::uintmax_t a, boost::uintmax_t b, boost::uintmax_t m) 32 inline div_t muldivmod(boost::uintmax_t a, boost::uintmax_t b, boost::uintmax_t m)
33 { 33 {
34 static const int bits = 34 const int bits =
35 ::std::numeric_limits< ::boost::uintmax_t>::digits / 2; 35 ::std::numeric_limits< ::boost::uintmax_t>::digits / 2;
36 static const ::boost::uintmax_t mask = (::boost::uintmax_t(1) << bits) - 1; 36 const ::boost::uintmax_t mask = (::boost::uintmax_t(1) << bits) - 1;
37 typedef ::boost::uint_t<bits>::fast digit_t; 37 typedef ::boost::uint_t<bits>::fast digit_t;
38 38
39 int shift = std::numeric_limits< ::boost::uintmax_t>::digits - 1 39 int shift = std::numeric_limits< ::boost::uintmax_t>::digits - 1
40 - detail::integer_log2(m); 40 - detail::integer_log2(m);
41 41
94 q -= error; 94 q -= error;
95 rem = rem + error * m - diff; 95 rem = rem + error * m - diff;
96 96
97 quotient[i - 2] = q; 97 quotient[i - 2] = q;
98 product[i] = 0; 98 product[i] = 0;
99 product[i-1] = (rem >> bits) & mask; 99 product[i-1] = static_cast<digit_t>((rem >> bits) & mask);
100 product[i-2] = rem & mask; 100 product[i-2] = static_cast<digit_t>(rem & mask);
101 } 101 }
102 102
103 div_t result = { 103 div_t result = {
104 ((::boost::uintmax_t(quotient[1]) << bits) | quotient[0]), 104 ((::boost::uintmax_t(quotient[1]) << bits) | quotient[0]),
105 ((::boost::uintmax_t(product[1]) << bits) | product[0]) >> shift, 105 ((::boost::uintmax_t(product[1]) << bits) | product[0]) >> shift,