Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Surprise: RAND() is an integer
Message
De
12/01/2006 10:51:36
 
 
À
12/01/2006 09:58:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01085963
Message ID:
01086094
Vues:
25
>>and certainly RAND() cannot return 1.
>
>I'll address only this aspect of your message. A bunch of us fought to have RAND() return only one of 0 and 1. Otherwise, it's too hard to spread the return value evenly over a range.
>
>Before VFP 5, RAND() could return both 0 and 1, each of them rarely. It made turning random values into a range (m,n) very difficult. With no 1's, we can also do INT(n * RAND()) + 1 to get values from 1 to n and know they'll be properly distributed.
>
>Tamar

Of course.

Tamar, if this can interest you,
I have discovered this thing, this morning,
while I was using BINTOC(,"B") to produce a pseudocasual string
with a more rapid way in comparison to the banal solution CHR(RAND()*256).
It has immediately appeared that
only the first part of the mantissa was not zero.
The rest is obvious consequence...

Fabio
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform