Andrey A. Chernov
476d9314d6
1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,
...
but ACM formula we use have internal state (and return value) in the
[1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached
because it is off by one, zero is not reached too.
Correct both RAND_MAX and rand(3) return value, shifting last one
to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)]
range.
2) Add a checks for not overflowing on too big seeds. It may happens on
the machines, where sizeof(unsigned int) > 32 bits.
Reviewed by: bde [1]
MFC after: 2 weeks
2013-07-03 21:21:54 +00:00
..
2013-05-21 21:20:10 +00:00
2013-06-30 07:46:22 +00:00
2013-05-21 21:50:11 +00:00
2012-10-04 04:15:18 +00:00
2013-04-17 11:42:40 +00:00
2013-05-21 19:59:37 +00:00
2010-02-16 19:39:50 +00:00
2010-02-16 19:39:50 +00:00
2010-02-16 19:39:50 +00:00
2011-12-29 14:41:17 +00:00
2013-05-30 04:49:26 +00:00
2012-03-28 12:11:54 +00:00
2010-02-16 19:39:50 +00:00
2012-05-19 12:44:27 +00:00
2012-01-07 10:33:01 +00:00
2010-02-16 19:39:50 +00:00
2012-06-05 19:42:57 +00:00
2010-02-16 19:39:50 +00:00
2010-02-16 19:39:50 +00:00
2013-05-21 21:20:10 +00:00
2010-02-16 19:28:10 +00:00
2011-12-20 22:56:13 +00:00
2012-10-19 12:44:22 +00:00
2010-02-16 19:28:10 +00:00
2013-07-03 07:03:19 +00:00
2011-10-21 06:41:46 +00:00
2013-05-21 21:20:10 +00:00
2012-03-28 12:11:54 +00:00
2011-09-27 16:33:17 +00:00
2012-03-28 12:11:54 +00:00
2009-10-06 14:05:57 +00:00
2011-03-04 19:28:27 +00:00
2012-03-04 15:31:13 +00:00
2013-06-28 21:00:08 +00:00
2013-05-25 18:59:11 +00:00
2010-02-16 19:39:50 +00:00
2012-03-28 12:11:54 +00:00
2010-02-16 19:39:50 +00:00
2012-09-10 05:12:45 +00:00
2010-02-16 19:39:50 +00:00
2011-12-13 13:32:56 +00:00
2010-02-16 19:28:10 +00:00
2010-02-16 19:39:50 +00:00
2010-04-04 08:31:03 +00:00
2013-06-27 18:28:45 +00:00
2012-07-04 17:35:07 +00:00
2011-02-07 21:26:46 +00:00
2011-01-06 03:30:16 +00:00
2012-10-19 12:44:22 +00:00
2010-02-16 19:39:50 +00:00
2010-11-13 10:38:06 +00:00
2011-12-13 13:32:56 +00:00
2012-01-07 16:10:15 +00:00
2012-03-06 20:15:23 +00:00
2010-01-05 02:37:59 +00:00
2012-04-29 11:04:31 +00:00
2011-12-13 13:32:56 +00:00
2010-02-16 19:39:50 +00:00
2011-12-25 20:51:40 +00:00
2011-12-25 20:15:41 +00:00
2010-02-16 19:39:50 +00:00
2013-02-27 19:50:46 +00:00
2013-07-03 21:21:54 +00:00
2012-01-03 23:05:23 +00:00
2013-02-14 19:26:58 +00:00
2013-04-23 13:03:03 +00:00
2010-01-04 18:46:54 +00:00
2010-02-16 19:39:50 +00:00
2010-02-16 19:39:50 +00:00
2010-11-02 17:00:56 +00:00
2013-04-27 21:18:34 +00:00
2013-01-14 18:01:19 +00:00
2010-02-16 19:39:50 +00:00
2010-02-16 19:39:50 +00:00
2013-05-25 16:58:12 +00:00
2013-05-01 22:42:42 +00:00
2010-09-30 03:16:35 +00:00
2010-02-16 19:39:50 +00:00
2010-01-13 17:29:55 +00:00
2008-09-15 23:47:19 +00:00
2013-02-27 19:50:46 +00:00
2012-03-04 15:31:13 +00:00
2012-03-04 15:31:13 +00:00