item random() (was Random(3) often returns 1)

Dar Scott dsc at swcp.com
Fri Jun 9 14:54:58 EDT 2006


On Jun 8, 2006, at 6:36 PM, Mark Smith wrote:

> Perhaps there is something weird about what the random() function  
> returns, until it is put into a variable?

The last I look, an array element will retain the inner numerical  
nature of a value and I assume random() returns something like that.   
However, a key is always a string and the number is converted to a  
numeral.  Sometimes that can be a problem, but Geoff's listing should  
have exposed that.

I suspect the problem is not in random() per se.  This is very  
similar to the recent base64 problem.  They may be unrelated, but I  
suspect a common bug or, more likely, a common theme.  It seems to  
have something to do with nested expressions.  It may be that calling  
a functions messes up a parameter of the outside function.

In any case, this is core and, to me, scary!

(BTW, I noticed that getting the randomSeed gets what it was last set  
to, not the current value.  That is perhaps a security concern.  I  
don't think it was that way back in 2.1 when I figured out how it was  
initialized then.)

This is unrelated to the problem of too small of a random() parameter  
for sorting.

Whose BZ is this?

Dar Scott



More information about the use-livecode mailing list