Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Number
Message
 
 
À
27/11/2001 08:46:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00585489
Message ID:
00586264
Vues:
29
>>>>>Hi all:
>>>>>
>>>>>How do I get a random number between 1 and 1000 in VFP6
>>>>>I could not find it in help.
>>>>>
>>>>>Thank you.
>>>>
>>>>
? INT(1000 * RAND( ) + 1)
>>>Instead of using 1000 in the equation above, use 999. The +1 could give you 1001, if RAND() returns 1 which it could.
>>
>>Right. Than the code that generates random integers in the specified range would be
>>lnRandMin = 1
>>lnRandMax = 1000
>>
>>? INT((lnRandMax - lnRandMin) * RAND( ) + lnRandMin)
>>
Correct?
>
>I think you should use round() rather than int(), see my other replies,
Is this ok with you? :)
lnRandMin = 1
lnRandMax = 1000

? RAND((lnRandMax - lnRandMin) * RAND( ) + lnRandMin,0)
> though I'm not convinced rand() returns 1.0

I know it does, see my other post in this thread. :)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform