Date: Sun, 02 Feb 2003 20:59:08 +0000 From: Mark Murray <mark@grondar.org> To: Bakul Shah <bakul@bitblocks.com> Cc: current@FreeBSD.ORG Subject: Re: rand() is broken Message-ID: <200302022059.h12Kx8aX051383@grimreaper.grondar.org> In-Reply-To: Your message of "Sun, 02 Feb 2003 12:39:50 PST." <200302022039.PAA13951@warspite.cnchost.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Bakul Shah writes:
> Note that it is rand() that is broken, not random() as can be
> seen by modifying Kris Kennaways' test so I don't see why
> Mark Murray was talking about changing it in the first place.
rand(3) says:
STANDARDS
     The rand() and srand() functions conform to ISO/IEC 9899:1990
     (``ISO C89'').
rand(3) does not specify an exact algorithm (the man page does, but
not the standard).  random(3) has no such standardisation.
Any code that assumes particular constants is _broken_[1]. If it
has been recompiled or if it is dynamically linked against a shared
library other than the one it was tested aginst, different results
are a _feature_.
M
[1] no nitpicking on INT_MAX, please.
--
Mark Murray
iumop ap!sdn w,I idlaH
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302022059.h12Kx8aX051383>
