Random Issue

Pierre
2007-03-02
2013-04-22
  • Pierre

    Pierre - 2007-03-02

    Hi again,

    A tiny problem: it *seems* that the last element of a random list is never chosen.

    In random.cs :

    I replaced
    XmlNode chosenNode = (XmlNode)listNodes[r.Next(listNodes.Count-1)];

    by
    XmlNode chosenNode = (XmlNode)listNodes[r.Next(listNodes.Count)];

    and now my last elements occur too.

    Don't you have this problem too?

    Pierre

     
    • Nicholas Tollervey

      Hi Pierre,

      Thanks for spotting this! My fault completely - I incorrectly thought that the max-number supplied to the Next method of a random object was inclusive - it obviously isn't! I should RTFM! I've fixed it in the subversion repository.

      Thanks,

      Nicholas

       
    • Nicholas Tollervey

      The 2.4.1 release now fixes this problem.

       
    • Pierre

      Pierre - 2007-03-02

      Perfect ;)

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks