uniform_real_distribution
constructorSection: 29.5.9.2.2 [rand.dist.uni.real] Status: C++17 Submitter: Marshall Clow Opened: 2012-07-14 Last modified: 2017-07-30
Priority: 3
View all issues with C++17 status.
Discussion:
uniform_real says in 29.5.9.2.2 [rand.dist.uni.real] p1:
A
uniform_real_distribution
random number distribution produces random numbersx
,a ≤ x < b
,
but also that (29.5.9.2.2 [rand.dist.uni.real] p2):
explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);-2- Requires:
a ≤ b
andb - a ≤ numeric_limits<RealType>::max()
.
If you construct a uniform_real_distribution<RealType>(a, b)
where there are no representable
numbers between 'a' and 'b' (using RealType
's representation) then you cannot satisfy
29.5.9.2.2 [rand.dist.uni.real].
a == b
.
[2014-11-04 Urbana]
Jonathan provides wording.
[2014-11-08 Urbana]
Moved to Ready with the note.
There remains concern that the constructors are permitting values that may (or may not) be strictly outside the domain of the function, but that is a concern that affects the design of the random number facility as a whole, and should be addressed by a paper reviewing and addressing the whole clause, not picked up in the issues list one distribution at a time. It is still not clear that such a paper would be uncontroversial.
Proposed resolution:
This wording is relative to N4140.
Add a note after paragraph 1 before the synopsis in 29.5.9.2.2 [rand.dist.uni.real]:
-1- A
uniform_real_distribution
random number distribution produces random numbers , , distributed according to the constant probability density function.
[Note: This implies that is undefined when
a == b
. — end note]
Drafting note: should be in math font, and
a == b
should be in code font.