|
Floats
Oct 22, 2008 14:14:39 GMT -5
Post by Nicky Peter Hollyoake on Oct 22, 2008 14:14:39 GMT -5
Can you put something on to make a caculation in real numbers? Anything would do.
Dim R1 = |RND()/RND_MAX
How about "|"? Does nothing in Basic4GL langauge anyways. or ...
Dim R1 = F(RND()/RND_MAX)
Would really be useful them timing the number by 1.0 all the time.
- Nicky
|
|
|
Floats
Oct 22, 2008 19:05:38 GMT -5
Post by Adam on Oct 22, 2008 19:05:38 GMT -5
Why dont you just divide it?
Dim R1 = (RND()%RND_MAX)/RND_MAX
|
|
|
Floats
Oct 28, 2008 16:35:39 GMT -5
Post by andrian on Oct 28, 2008 16:35:39 GMT -5
to do so, you need to multiply by a float
what nicky is asking for is type casting to float, so that calculations will be done with floating point variables instead of integers, which round off at the whole number.
your example would use integer division, which is where floats are most dangerous because the often end up being very wrong.
dim r1# = 1/100
gives you zero
|
|
|
Floats
Oct 28, 2008 22:59:34 GMT -5
Post by Adam on Oct 28, 2008 22:59:34 GMT -5
ok then lol
Dim R1# = (RND()%RND_MAX)/(RND_MAX*1.0)
|
|
|
Floats
Oct 29, 2008 5:12:24 GMT -5
Post by Nicky Peter Hollyoake on Oct 29, 2008 5:12:24 GMT -5
Thats just the same as doing ...
Print RND()/(RND_MAX*1.0)
... though. ;\
|
|
|
Floats
Nov 1, 2008 6:13:43 GMT -5
Post by Supermonkey on Nov 1, 2008 6:13:43 GMT -5
If typecasting were to be added I think the best syntax would be
print (RND()/RND_MAX) as float
or something similar.
|
|