Liste des Groupes | Revenir à cl awk |
A deliberately chosen seed of 0 gets overwritten?
How about (since you're expecting a number)
if (SEED=="") SEED = 1
or (for good measure) the more general pattern for
an "uninitialized" variable 'var'
if (var=="" && var==0) ... # uninitialized
else ... # initialized (including "" and 0)
But is a seed of 1 "better" than a seed of 0 ?
Both create deterministic random number sequences.
Only srand() (i.e. without argument) creates a
time-depending quasi non-deterministic sequence.
My choice would probably be
if (var=="" && var==0) srand() # random start
else srand(var) # deterministic
to have both options.
Les messages affichés proviennent d'usenet.