random number
Harry1
Posts: 29
how do i generate a random number from 0 to 22
thanks!
thanks!
Comments
myvar is your variable that holds the random number
random is the resulting random number from 0 to 22
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
Post Edited (TChapman) : 3/27/2007 8:10:07 PM GMT
http://forums.parallax.com/showthread.php?p=639978
It takes 32 longs of code space and 2 longs for variables. It takes one cog, but you only need to run it when you need a new random number:
OBJ
· rr : "RealRandom"
PRI random_0_to_22 : value
· rr.start
· value := ||rr.random // 23
· rr.stop
This will never yield a repeating pattern.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 3/27/2007 9:05:57 PM GMT