PR libstdc++/39644 (partial)

2009-04-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/39644 (partial)
	* include/bits/random.tcc (linear_congruential_engine<>::
	seed(seed_seq&), independent_bits_engine<>::operator(),
	generate_canonical(_UniformRandomNumberGenerator&)): Avoid log2l.

From-SVN: r145563
This commit is contained in:
Paolo Carlini 2009-04-05 16:56:16 +00:00 committed by Paolo Carlini
parent bb2aaded92
commit 2fcf6ffb76
2 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2009-04-05 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/39644 (partial)
* include/bits/random.tcc (linear_congruential_engine<>::
seed(seed_seq&), independent_bits_engine<>::operator(),
generate_canonical(_UniformRandomNumberGenerator&)): Avoid log2l.
2009-04-04 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/bits/random.h (struct _ShiftMin1): Fix small typo and

View File

@ -118,7 +118,9 @@ namespace std
linear_congruential_engine<_UIntType, __a, __c, __m>::
seed(seed_seq& __q)
{
const _UIntType __k = (std::log2(__m) + 31) / 32;
const _UIntType __k0 = __m == 0 ? std::numeric_limits<_UIntType>::digits
: (std::__lg(__m) + 31);
const _UIntType __k = __k0 / 32;
_UIntType __arr[__k + 3];
__q.generate(__arr + 0, __arr + 3);
_UIntType __factor = 1U;
@ -130,7 +132,7 @@ namespace std
}
if ((__detail::__mod<_UIntType, 1U, 0U, __m>(__c) == 0U)
&& (__detail::__mod<_UIntType, 1U, 0U, __m>(__sum) == 0U))
&& (__detail::__mod<_UIntType, 1U, 0U, __m>(__sum) == 0U))
_M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(1U);
else
_M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(__sum);
@ -578,7 +580,7 @@ namespace std
{
const long double __r = static_cast<long double>(this->max())
- static_cast<long double>(this->min()) + 1.0L;
const result_type __m = std::log2l(__r);
const result_type __m = std::log10(__r) / std::log10(2.0L);
result_type __n, __n0, __y0, __y1, __s0, __s1;
for (size_t __i = 0; __i < 2; ++__i)
{
@ -2762,7 +2764,7 @@ namespace std
__bits);
const long double __r = static_cast<long double>(__urng.max())
- static_cast<long double>(__urng.min()) + 1.0L;
const size_t __log2r = std::log2l(__r);
const size_t __log2r = std::log10(__r) / std::log10(2.0L);
size_t __k = std::max<size_t>(1UL, (__b + __log2r - 1UL) / __log2r);
_RealType __sum = _RealType(0);
_RealType __tmp = _RealType(1);