Is there a UNIX SVR2 random/srandom equivalent?

Guy Harris guy at sun.uucp
Tue Jul 16 18:00:26 AEST 1985


> 	In particular, while BSD and sysV RNGs both return ints, you
> must pay attention to what an int is. On a local VAX 11/750 an int is 4
> bytes. On our 3B20S an int is 2 bytes.

Geepers, that flies in the face of whatever I've heard about the 3B20.
(BTW, I think the changes of the size of an "int" being different on other
VAXes, even if they're different models, are somewhere between zip, zero,
and nil.)  What I think you mean to say is

	In particular, while 4.xBSD and (PDP-11 V7/System III/System V) RNGs
	both return "int"s, you must pay attention to what subrange of the
	range of an "int" they return.  On 4.xBSD they return a number in
	the range 0 - 2^31 - 1.  On Systems III and V, and on V7
	implementations on 16-bit machines, they return a number in the range
	0 - 2^15 - 1.  (On UNIX/32V it returns a number in the range
	0 - 2^31 - 1, which is presumably why 4.xBSD does so also.  I presume
	they decided to make it return the same range on 16-bit-"int" and
	32-bit-"int" machines in System III - or UNIX/TS - to make it
	possible to reduce the result of "rand" to a fixed range without
	#ifdefing code for different "int" sizes.)

	Guy Harris



More information about the Comp.unix mailing list