Click here to Skip to main content
15,901,122 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Create Random number Pin
Maximilien1-Aug-05 2:30
Maximilien1-Aug-05 2:30 
GeneralRe: Create Random number Pin
Halawlaws1-Aug-05 2:32
Halawlaws1-Aug-05 2:32 
GeneralRe: Create Random number Pin
Maximilien1-Aug-05 2:35
Maximilien1-Aug-05 2:35 
GeneralRe: Create Random number Pin
Halawlaws1-Aug-05 2:36
Halawlaws1-Aug-05 2:36 
GeneralRe: Create Random number Pin
David Crow1-Aug-05 3:12
David Crow1-Aug-05 3:12 
GeneralRe: Create Random number Pin
Chris Losinger1-Aug-05 4:56
professionalChris Losinger1-Aug-05 4:56 
GeneralRe: Create Random number Pin
David Crow1-Aug-05 3:07
David Crow1-Aug-05 3:07 
GeneralRe: Create Random number Pin
knapak1-Aug-05 11:26
knapak1-Aug-05 11:26 
Hello

In my opinion, a better way to do what you need is to use one of the random number generator routines in "NUMERICAL RECIPIES": http://www.library.cornell.edu/nr/cbookcpdf.html

Scroll down to Ch. 7 in that page and you'll find a lot of algorithms that will be by far better you can come up using only your machine generator. You'll still need it, but the algorithms provide better "randomness" in your numbers and they are sorted by the way you need them to have certain statistical distributions. If you need them to have equal probabilities, then use the ran2 algorithm. This code is an implementation of it:

seed = 0;<br />
srand (time(NULL));<br />
rand();<br />
seed = rand();<br />
return ran2(seed);<br />

The return number is a uniform random deviate between 0 and 1. If you need integers just multiply your number as needed and take the integer.

Cheers
GeneralHelp needed for calculating font height.!! Pin
Rajesh_Parameswaran1-Aug-05 1:32
Rajesh_Parameswaran1-Aug-05 1:32 
GeneralRe: Help needed for calculating font height.!! Pin
Ritu Kwatra1-Aug-05 1:41
Ritu Kwatra1-Aug-05 1:41 
GeneralRe: Help needed for calculating font height.!! Pin
Rajesh_Parameswaran1-Aug-05 21:14
Rajesh_Parameswaran1-Aug-05 21:14 
GeneralRe: Help needed for calculating font height.!! Pin
Ritu Kwatra1-Aug-05 23:43
Ritu Kwatra1-Aug-05 23:43 
Generalcasting CString to int Pin
Halawlaws1-Aug-05 1:30
Halawlaws1-Aug-05 1:30 
GeneralRe: casting CString to int Pin
toxcct1-Aug-05 1:32
toxcct1-Aug-05 1:32 
GeneralRe: casting CString to int Pin
Halawlaws1-Aug-05 1:41
Halawlaws1-Aug-05 1:41 
GeneralRe: casting CString to int Pin
toxcct1-Aug-05 1:49
toxcct1-Aug-05 1:49 
GeneralRe: casting CString to int Pin
Halawlaws1-Aug-05 1:49
Halawlaws1-Aug-05 1:49 
GeneralRe: casting CString to int Pin
Marc Soleda1-Aug-05 1:52
Marc Soleda1-Aug-05 1:52 
GeneralRe: casting CString to int Pin
Smith#1-Aug-05 2:05
Smith#1-Aug-05 2:05 
GeneralRe: casting CString to int Pin
Smith#1-Aug-05 2:06
Smith#1-Aug-05 2:06 
GeneralRe: casting CString to int Pin
Eytukan1-Aug-05 2:43
Eytukan1-Aug-05 2:43 
GeneralRe: casting CString to int Pin
toxcct1-Aug-05 3:40
toxcct1-Aug-05 3:40 
GeneralSerial number storing Pin
Halawlaws1-Aug-05 0:45
Halawlaws1-Aug-05 0:45 
GeneralRe: Serial number storing Pin
toxcct1-Aug-05 1:03
toxcct1-Aug-05 1:03 
GeneralRe: Serial number storing Pin
Halawlaws1-Aug-05 1:56
Halawlaws1-Aug-05 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.