Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A little confused with RAND()
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
A little confused with RAND()
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01392453
Message ID:
01392453
Views:
117
Hi,

Here is an example and the results with question inline:
SET DECIMALS TO 6
ldBaseDate = {^1900-01-01}
ldCurrDate = DATE()
RAND(ldCurrDate - ldBaseDate)
nTest = RAND()

? nTest    &&    This shows 0.031874

nTest = INT(nTest * 1000000)
? nTest    &&    This however shows 31873
Why the number 0.031874 turns into 31873 when multiplied by 1000000?

UPDATE: As soon as I posted, I think I get it. The number 0.031874 is actually something like 0.0318738 and is only showing 6 decimal numbers. But the INT() truncates it. Right?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform