Menu

Random

Help
2009-11-25
2013-05-30
  • David Stephenson

    How does the random number generator work?
    Is there a way of seeding it or do you get the same sequence each time it is called.

     
  • Hugh Considine

    Hugh Considine - 2009-11-27

    The random number generator in GCBASIC is a 16 bit linear feedback shift register, which is explained pretty well at .

    Generally, yes, you will get the same sequence every time it is used. However, you can seed it so that it will start at a different point at the sequence using the Randomize command. If you wanted to use an analog reading to seed the generator, this would work:

        Randomize ReadAD10(AN0)

    It appears I have neglected to cover this in the help, will write an article about it soon.

      : http://en.wikipedia.org/wiki/Linear_feedback_shift_register

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.