Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Generator
Message
De
22/01/2001 22:52:53
 
 
À
22/01/2001 22:46:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00467103
Message ID:
00467111
Vues:
15
>Why don't I have to reset the RAND() after each call?
>The manual says:
>'RAND( ) returns the same sequence of random numbers if you use the same seed value for nSeedValue the first time you issue RAND( ) followed by subsequent RAND( ) function calls without nSeedValue.'

That works like this:
* Set the seed for all subsequent Rand() without a seed
?rand(1) && 03
?rand()  && 25
?rand()  && 71
?rand()  && 48

* Now reset the seed
?rand(2) && 05
?rand()  && 06
?rand()  && 62
?rand()  && 36

* Now go back to the orginal seed
?rand(1) && 03
?rand()  && 25
?rand()  && 71
?rand()  && 48
THat code generates teh same out put no matter when you run it. The seed only needs to be set once, and thats at the beginning of the app, where you can do Rand(-1) which sets the seed based on the time.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform