Precision of rand()
G.R.Tomasevich
grt at twitch.UUCP
Sat Jul 20 08:02:46 AEST 1985
> It seems that I spoke too soon. Ints on our 3B20S are indeed 4 bytes
> long. rand() returns a 4 byte value BUT (this is the catch) the value is
> masked to its lower 15 bits yeilding 0 <= rand() <= 32767.
> --
> Edward C. Bennett
The length of the calculation has been 32 bits for a long time, even on
the PDP-11. The static variable, randx, is a long. See the source
routine, which is /usr/src/lib/libc/port/gen/rand.c on our machine.
--
George Tomasevich, ihnp4!twitch!grt
AT&T Bell Laboratories, Holmdel, NJ
More information about the Comp.unix
mailing list