Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Class template uniform_real



// In header: <boost/random/uniform_real.hpp>

template<typename RealType = double> 
class uniform_real {
  // types
  typedef RealType input_type; 
  typedef RealType result_type;

  // construct/copy/destruct
  uniform_real(RealType = RealType(0), RealType = RealType(1));

  // public member functions
  result_type min() const;
  result_type max() const;
  void reset();
  template<typename Engine> result_type operator()(Engine &);


The distribution function uniform_real models a random distribution. On each invocation, it returns a random floating-point value uniformly distributed in the range [min..max). The value is computed using std::numeric_limits<RealType>::digits random binary digits, i.e. the mantissa of the floating-point value is completely filled with random bits.

Note: The current implementation is buggy, because it may not fill all of the mantissa with random bits.

uniform_real public construct/copy/destruct

  1. uniform_real(RealType min_arg = RealType(0), RealType max_arg = RealType(1));

    Constructs a uniform_real object. min and max are the parameters of the distribution.

    Requires: min <= max

uniform_real public member functions

  1. result_type min() const;

    Returns: The "min" parameter of the distribution

  2. result_type max() const;

    Returns: The "max" parameter of the distribution

  3. void reset();
  4. template<typename Engine> result_type operator()(Engine & eng);