How to generate a random number between 0 and 1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My program needs a random number between 0 and 1 (0, 1). Who can tell me how to do this? Thanks in advance

Richar

(e-mail address removed)
 
=?Utf-8?B?UmljaGFyZA==?= said:
My program needs a random number between 0 and 1 (0, 1). Who can tell
me how to do this? Thanks in advance.

C: rand
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/vclib/html/_CRT_rand.asp

and some small calculation like
double random()
{
return ((double) rand()) / (double) RAND_MAX;
}



Managed C++:

declare:
static rnd = new System.Random();

and use:
rnd.NextDouble();

See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfsystemrandomclassnextdoubletopic.asp



--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
 
Back
Top