Random(3) often returns 1
dsc at swcp.com
Thu Jun 8 12:43:14 CDT 2006
On Jun 8, 2006, at 7:00 AM, Sarah Reichelt wrote:
> I think if you sort using only the number of lines as your randomiser,
> you will get some lines with the same sort value and so their order
> will remain the same.
> When doing this type of sort, I alwasy got for a ridiculously large
> randome number to reduce this possibility e.g.
> sort lines of fld "Answers" by random(1000000)
This is right. Function random() is called once for each line,
assigning that a number to that line. That number is used to sort
the lines. The smaller the parameter to random, the greater the
chance that two lines end up with the same number. If two lines have
the same number, they will sort in the same order that they had.
(There is also a minor problem that random(n) has will favor smaller
numbers for n>100,000,000. Also, don't use n>2,000,000,000. Sarah's
n=1,000,000 is good.)
More information about the use-livecode