G Guest Mar 30, 2004 #1 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)
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)
J Jochen Kalmbach Mar 30, 2004 #2 =?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. Click to expand... 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/
=?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. Click to expand... 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/
G Guest Mar 30, 2004 #3 #include <stdio.h float number = rand() / (float) RAND_MAX I think... didn't tried it :0)