Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!novavax!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: Random number generator Message-ID: <1989Dec24.175914.813@twwells.com> Date: 24 Dec 89 17:59:14 GMT References: <83943@linus.UUCP> <940001@hpavla.HP.COM> Organization: None, Ft. Lauderdale, FL Lines: 19 In article <940001@hpavla.HP.COM> gary@hpavla.HP.COM (Gary Jackoway) writes: : longrand = (unsigned long) rand() | ((unsigned long) rand() << 32); ^16? Note that normally this code would be incorrect C code, in that it twice evaluates a function that might produce different effects on each invocation in such a way that the order of evaluation is undefined. But because rand() ought to be random, it should not matter which order you get the results in. So, in this rare case, you can get away with it. There is a cost, however: since the order of evaluation is undefined, the compiler might choose to do it either way in any given compilation, which could make reproducing the results of your program difficult. (Say, for debugging.) --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com