[MonoDevelop] Real Range Random Generation

Federico Di Gregorio fog at initd.org
Tue Oct 19 16:30:16 EDT 2010


On 19/10/2010 22:16, Ahmed Abdeen Hamed wrote:
> Hello,
> Is there is a straightforward way to generate random real numbers of a
> range say -15.25 : 32.78 ?
> I would appreciate any help,

Questions like this one are better posted to places like StackOverflow.
Anyway this is a solution to the problem:

Random r = new Random();
Console.WriteLine((32.78 - (-15.25)) * r.NextDouble() - 15.25);

-- 
Federico Di Gregorio                                       fog at initd.org
 If a process is potentially good, but 90%+ of the time smart and
  well-intentioned people screw it up, then it's a bad process.
                                                          -- Steve Yegge


More information about the Monodevelop-list mailing list