
Hello, Darren. --- Darren Cook <darren@dcook.org> wrote:
What I wanted to do was generate a random number in the full range of an integer template parameter, e.g. whether I used the template with unsigned char, or a 128-bit integer. (in the end I decided to come back to this when I needed that flexibility and implemented using 32-bit integers and the standard library's srand48() and mrand48()).
So, can Boost.Random generate a random number to match the type?
This should be possible. Try boost::uniform_int<T> dist( (std::numeric_limits<T>::min)(), (std::numeric_limits<T>::max)() ); as your distribution. (The extra parentheses arise from a recent thread on using min/max.) For a user-defined type such as your 128-bit integer, you'll have to provide a template specialization of std::numeric_limits before creating the distribution. Make sure your base rng engine can actually cover at least the integer range specified in std::numeric_limits; boost::mt19937 should be good enough for your purposes. HTH Cromwell Enage __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail