Title
inconsistencies in the definitions of rand() and random_shuffle()
Status
cd1
Section
[c.math]
Submitter
James Kanze

Created on 2003-01-03.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The original proposed resolution proposed requiring the two-argument from of random_shuffle to use rand. We don't want to do that, because some existing implementations already use something else: gcc uses lrand48, for example. Using rand presents a problem if the number of elements in the sequence is greater than RAND_MAX.

Date: 2010-10-21.18:28:33

Proposed resolution:

In [lib.c.math], add a paragraph specifying that the C definition of rand shal be modified to say that "Unless otherwise specified, the implementation shall behave as if no library function calls the rand function."

In [lib.alg.random.shuffle], add a sentence to the effect that "In the two argument form of the function, the underlying source of random numbers is implementation defined. [Note: in particular, an implementation is permitted to use rand.]

Date: 2003-01-03.00:00:00

In [c.math], the C++ standard refers to the C standard for the definition of rand(); in the C standard, it is written that "The implementation shall behave as if no library function calls the rand function."

In [alg.random.shuffle], there is no specification as to how the two parameter version of the function generates its random value. I believe that all current implementations in fact call rand() (in contradiction with the requirement avove); if an implementation does not call rand(), there is the question of how whatever random generator it does use is seeded. Something is missing.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2470
2010-10-21 18:28:33adminsetmessages: + msg2469
2003-01-03 00:00:00admincreate