From owner-freebsd-hackers Fri Oct 4 11:31:56 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id LAA05589 for hackers-outgoing; Fri, 4 Oct 1996 11:31:56 -0700 (PDT) Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id LAA05583 for ; Fri, 4 Oct 1996 11:31:53 -0700 (PDT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id UAA29260 for ; Fri, 4 Oct 1996 20:31:50 +0200 Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id UAA00944 for freebsd-hackers@freebsd.org; Fri, 4 Oct 1996 20:31:49 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.7.5/8.6.9) id UAA03607 for freebsd-hackers@freebsd.org; Fri, 4 Oct 1996 20:22:33 +0200 (MET DST) From: J Wunsch Message-Id: <199610041822.UAA03607@uriah.heep.sax.de> Subject: Re: rand() and random() To: freebsd-hackers@freebsd.org (FreeBSD hackers) Date: Fri, 4 Oct 1996 20:22:33 +0200 (MET DST) Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199610031538.BAA19908@godzilla.zeta.org.au> from Bruce Evans at "Oct 4, 96 01:38:16 am" X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E X-Mailer: ELM [version 2.4ME+ PL17 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Bruce Evans wrote: > >That doesn't mean it would be impossible to do > > > >int > >rand(void) > >{ > > return (int)random(); > >} > > It would have to use a copy of random() so that the functions don't > mess up each other's state. ...unless it's documented that they mess with it. :) It's unlikely that one program uses both functions (and if so, it's as likely that the lousy programmer would have messed rand()'s state with rand() in another place as well ;-). > >I vote for killing the old rand(). Too many things (in particular, > >games) behave very stupid with it. > > Are they better with rand() replaced by (rand() % 0x7fff)? I don't think so. But they are much better with random(). See xmine, if you wanna get a nice example. It generates totally predictable layouts when using rand(). -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)