🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.transputer
Article #792

Re: Random numbers

#792
From: Peter S. Shenkin
Date: Tue, 24 Jul 1990 13:38
22 lines
1656 bytes
In article <483@keele.keele.ac.uk> writes:

>My problem is that C has the two routines srand and rand. The latter
>returning an integer in the range 0-32767 (0 -> (2^15)-1). If I am

C has no such thing.  UNIX has such things.  Rand and srand are outdated
relics of the PDP-11 era, and have been replaced on almost all (?) UNIX
systems by random and srandom, which return 32-bit values.  If your UNIX
system supports these, use them and avoid the problem!

In any case, even on 32-bit UNIX machines when called from C, rand returns
random values only in the 16 high-order bits, so when using these functions
even from C it is necessary to do a 16-bit shift to the "right".  Without
this, the sequence of numbers returned alternates strictly between even
and odd (at least it did on a VAX running ULTRIX) -- scarcely pseudorandom
behavior!

	-P.
************************f*u*cn*rd*ths*u*cn*gt*a*gd*jb**************************
Peter S. Shenkin, Department of Chemistry, Barnard College, New York, NY  10027
(212)854-1418  shenkin@cunixc.cc.columbia.edu(Internet)  shenkin@cunixc(Bitnet)
***"In scenic New York... where the third world is only a subway ride away."***
Technical Details
Message-ID: <1990Jul24.133823.6608@cunixf.cc.columbia.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mailrus!tut.cis.ohio-state.edu!rutgers!cunixf.cc.columbia.edu!shenkin
References: <483@keele.keele.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mailrus!tut.cis.ohio-state.edu!rutgers!cunixf.cc.columbia.edu!shenkin
From: shenkin@cunixf.cc.columbia.edu (Peter S. Shenkin)
Newsgroups: comp.sys.transputer,comp.lang.fortran
Subject: Re: Random numbers
Message-ID: <1990Jul24.133823.6608@cunixf.cc.columbia.edu>
Date: 24 Jul 90 13:38:23 GMT
References: <483@keele.keele.ac.uk>
Reply-To: shenkin@cunixf.cc.columbia.edu (Peter S. Shenkin)
Organization: Columbia University
Lines: 22