On Wed, 3 Jul 2013, Andrey Chernov wrote:
On 02.07.2013 20:33, Bruce Evans wrote:
I checked the values returned by rand(). The ACM part works as
intended, so it never returns RAND_MAX. It also never returns 0. So
the distribution of values in the documented range [0, RAND_MAX] is
very non-uniform. It is uniform in [1, RAND_MAX - 1]. To use this
algorithm for rand(), 1 should have been subtracted, giving a range
of [0, 0x7ffffffe].
Do you mean [0, 0x7ffffffd] (assuming 1 subtracted)?
Yes.
See attached patch.
I don't see compatibility problems at least from POSIX specs point of
view - they don't say something specific about RAND_MAX.
I like the patch. It is binary compatibility problems and maybe applications
assuming that (RAND_MAX + 1) is 0x80000000 so as to do magic bit operations
with it that may be problems.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"