In comp.lang.c.moderated James Kanze <> wrote:
>
> I'm sorry, but it fails just about every known test. To begin
> with, the results alternate between even and odd.
No it doesn't. The code again from the C standard is:
static unsigned long int next = 1;
int rand(void) // RAND_MAX assumed to be 32767
{
next = next * 1103515245 + 12345;
return (unsigned int)(next/65536) % 32768;
}
Note the "/65536" in the return line that yields the high-order 15 bits
of the result, not the low-order. You're thinking of the brain-damaged
variant that originated at Berkeley (and apparently lives on in glibc)
that increases the range to 31 bits by eliminating the division and
increasing the modulus. That *does* fail just about every known test
and is infamously bad. Please don't tar the version in the Standard
with the same brush.
--
Larry Jones
Monopoly is more fun when you make your own Chance cards. -- Calvin
--
comp.lang.c.moderated - moderation address:
-- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.