You're right, Brian--I was coding from memory and left out an expression in the fifth line:
That will generate the values 1 to 10.Code:SEED=32771 LOOP: RANDOM SEED TIME=(SEED//11)+1 IF TIME<2 OR TIME>10 THEN GOTO LOOP TIME=1000*(TIME-1) HIGH LED PAUSE TIME LOW LED PAUSE 1000 GOTO LOOP END
I've had to use a similar trick before with other forms of BASIC, notably a tinyBASIC implementation for the 8051 family, because the "ends" of the range (1 and 10) came up disproportionately often.
If you were satisfied with the distribution based on your empirical test, then it's certainly good enough for any applications I have in mind.
Thanks for a really good answer!





Bookmarks