1 #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
2 #define BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
4 // Copyright 2017 Peter Dimov
6 // Distributed under the Boost Software License, Version 1.0.
8 // See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt
11 // An implementation of minstd_rand that does not require
14 #include <boost/cstdint.hpp>
25 boost::uint_least32_t x_;
27 enum { a = 48271, m = 2147483647 };
31 minstd_rand(): x_( 1 )
35 explicit minstd_rand( boost::uint_least32_t x ): x_( x % m )
43 boost::uint_least32_t operator()()
45 boost::uint_least64_t y = x_;
49 x_ = static_cast<boost::uint_least32_t>( y );
58 #endif // #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED