Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!sgi!arisia!quintus!ok From: ok@quintus Newsgroups: comp.bugs.4bsd Subject: SunOS3.2 rand(3) manual error Message-ID: <753@quintus.UUCP> Date: 27 Nov 88 05:44:23 GMT Sender: news@quintus.UUCP Reply-To: ok@quintus () Organization: Quintus Computer Systems, Inc. Lines: 24 The SunOS 3.2 on-line manual page for rand(3v) says: rand uses a multiplicative congruential random number gen- erator with period 2**32 to return successive pseudo-random numbers in the range from 0 to (2**15)-1. In fact it generates 31-bit integers, as the following test program shows: main() { extern int rand(); extern void srand(); int i; srand(21345); for (i = 1; i <= 20; i++) printf("%12d\n", rand()); } -- This program generates identical results on a Sun-3/60 and a Sequent 386. The Sequent documentation describes the range correctly. The SVID specifies 15-bit results. The BSD/SV incompatibility is known, but it looked as though SunOS 3.2 had adopted the SV definition. Nope, you still need (rand()&32767) for portability.