Need Help generating Random number LIMIT
mrdontay
Posts: 3
How do i generate a number between 1 and 6 . By default the RANDOM fuction in Pbasic generates a number between 0 and 65535 using a "seed" number as a starting point.
Here is the code I need to modify or if there is a better way please let me know. Thanks
result· VAR··· Word
Setup:
·· result = 1000···
Main
·· RANDOM result
·· DEBUG DEC ? result
·· GOTO MAIN
Here is the code I need to modify or if there is a better way please let me know. Thanks
result· VAR··· Word
Setup:
·· result = 1000···
Main
·· RANDOM result
·· DEBUG DEC ? result
·· GOTO MAIN
Comments
The modulus operator provides the remainder after division by 6 (in this case). That's between 0 and 5, so we add one.