Subject: [Boost-bugs] [Boost C++ Libraries] #2787: boost::random::detail::uniform_int_float constructor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-02-21 11:08:20
#2787: boost::random::detail::uniform_int_float constructor
------------------------------+---------------------------------------------
Reporter: rick68_at_[hidden] | Owner: steven_watanabe
Type: Patches | Status: new
Milestone: Boost 1.39.0 | Component: random
Version: Boost 1.38.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
Hi,
In <boost/random/detail/uniform_int_float.hpp>
line32: uniform_int_float(base_type rng, IntType min_arg = 0, IntType
max_arg = 0xffffffff)[[BR]]
line33: : _rng(rng), _min(min_arg), _max(max_arg)[[BR]]
line34: {[[BR]]
line35: init();[[BR]]
line36: }[[BR]]
line68: void init()[[BR]]
line69: {[[BR]]
line70: _range = static_cast<base_result>(_max-_min)+1;[[BR]]
line71: }[[BR]]
If IntType is "unsigned long" and "min_arg = 0", "max_arg = 0xffffffff";
after call constructor, _range will be zero.
Becouse "0 + 0xffffffff + 1" is 0, so when we call operator() anytime, it
always return 0.
Is it normal?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2787> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC