Click here to Skip to main content
15,902,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Coding droplist data in MFC Pin
keegan25-Jun-03 9:14
keegan25-Jun-03 9:14 
Generalrandom numbers rand() Pin
johnstonsk25-Jun-03 6:30
johnstonsk25-Jun-03 6:30 
GeneralRe: random numbers rand() Pin
Rob Caldecott25-Jun-03 6:38
Rob Caldecott25-Jun-03 6:38 
GeneralRe: random numbers rand() Pin
johnstonsk25-Jun-03 6:55
johnstonsk25-Jun-03 6:55 
GeneralRe: random numbers rand() Pin
David Crow25-Jun-03 7:01
David Crow25-Jun-03 7:01 
GeneralRe: random numbers rand() Pin
johnstonsk25-Jun-03 7:17
johnstonsk25-Jun-03 7:17 
GeneralRe: random numbers rand() Pin
Jamie Hale25-Jun-03 8:09
Jamie Hale25-Jun-03 8:09 
GeneralRe: random numbers rand() Pin
johnstonsk25-Jun-03 9:00
johnstonsk25-Jun-03 9:00 
When I divide by RAND_MAX, I get a 0 as the value.

When I divided by the mod I get a number between my min and max value, but it was a int.

How can I get the rand() to return a value between 2 doubles.

Here is my code, it might give you a better idea.

thanks,
sj

<br />
double createRandNum(TSimSignal &s, double min, double max){<br />
	<br />
		double n;	<br />
		<br />
		for(int i = 0; i < 100; i++){	<br />
		   n = min + ((double)rand()) % (max - min + 1.0));<br />
                                         or<br />
                   n = min + ((double)rand()/RAND-MAX) % ((double)(max - min + 1)));	<br />
				}<br />
		   cout << endl << "The random number is : " << rand()<< "  N is : " << n << "\n";<br />
		return n;<br />
}<br />
<br />

GeneralRe: random numbers rand() [edited] Pin
Jamie Hale25-Jun-03 9:16
Jamie Hale25-Jun-03 9:16 
GeneralExecutable Creation time Pin
gbenguita25-Jun-03 6:27
gbenguita25-Jun-03 6:27 
GeneralRe: Executable Creation time Pin
Rob Caldecott25-Jun-03 6:31
Rob Caldecott25-Jun-03 6:31 
GeneralHelp with EDCN2000N CCD Camera Software.... Pin
tonicito25-Jun-03 6:25
tonicito25-Jun-03 6:25 
GeneralRe: Help with EDCN2000N CCD Camera Software.... Pin
tonicito27-Jun-03 5:24
tonicito27-Jun-03 5:24 
Questionbug or my fault? Pin
nothingremained25-Jun-03 6:22
nothingremained25-Jun-03 6:22 
AnswerRe: bug or my fault? Pin
David Crow25-Jun-03 7:08
David Crow25-Jun-03 7:08 
QuestionMemory leak in CMapStringToOb - Why? Pin
pf725-Jun-03 5:53
pf725-Jun-03 5:53 
AnswerRe: Memory leak in CMapStringToOb - Why? Pin
pf725-Jun-03 8:45
pf725-Jun-03 8:45 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
basementman25-Jun-03 11:27
basementman25-Jun-03 11:27 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
pf725-Jun-03 11:58
pf725-Jun-03 11:58 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
pf726-Jun-03 3:52
pf726-Jun-03 3:52 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
John M. Drescher26-Jun-03 23:27
John M. Drescher26-Jun-03 23:27 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
pf727-Jun-03 4:17
pf727-Jun-03 4:17 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
John M. Drescher27-Jun-03 9:47
John M. Drescher27-Jun-03 9:47 
GeneralRe: Memory leak in CMapStringToOb - Why? Pin
pf727-Jun-03 11:29
pf727-Jun-03 11:29 
Generalmaximum characters in edit box Pin
skinnyreptile25-Jun-03 5:36
skinnyreptile25-Jun-03 5:36 

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.