asiftasleem / nbuilder

Automatically exported from code.google.com/p/nbuilder
0 stars 0 forks source link

RandomGenerator.Next(double min, double max) does not use its parameters and returns the wrong value #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In the class RandomGenerator.cs, the Next(double min, double max) method looks 
like this:

        public virtual double Next(double min, double max)
        {
            return rnd.NextDouble();
        }

where rnd = new Random();. This method does not use the min and max parameters 
and will always return a double between 0.0 and 0.999~. The code should be 
modified to:

        public virtual double Next(double min, double max)
        {
            return min + ((max - min) / rnd.NextDouble());
        }

Original issue reported on code.google.com by dft...@gmail.com on 9 Dec 2010 at 2:57

GoogleCodeExporter commented 8 years ago
Whoops, this is a duplicate of Issue 60, and my method is wrong anyway, I used 
division instead of multiplication.

    return min + ((max - min) * rnd.NextDouble());

Original comment by dft...@gmail.com on 9 Dec 2010 at 2:59