Click here to Skip to main content
15,905,073 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralOwn client/server and 10053 problem Pin
justin22326-Jun-03 6:31
justin22326-Jun-03 6:31 
GeneralRe: Own client/server and 10053 problem Pin
keegan26-Jun-03 6:35
keegan26-Jun-03 6:35 
GeneralRe: Own client/server and 10053 problem Pin
justin22326-Jun-03 7:21
justin22326-Jun-03 7:21 
GeneralRe: Own client/server and 10053 problem Pin
justin22326-Jun-03 7:27
justin22326-Jun-03 7:27 
GeneralRe: Own client/server and 10053 problem Pin
RobJones26-Jun-03 10:56
RobJones26-Jun-03 10:56 
GeneralVersion number Pin
Anonymous26-Jun-03 5:35
Anonymous26-Jun-03 5:35 
GeneralRe: Version number Pin
basementman26-Jun-03 6:33
basementman26-Jun-03 6:33 
GeneralI need AIR & I'm pulling my hair out over Random doubles within a specified range Pin
johnstonsk26-Jun-03 5:21
johnstonsk26-Jun-03 5:21 
I know I've been on the same problem for a day now, but I just can't get the numbers generated between a min and max value.
I really need to produce a double.
I have changed my function around 20 times and this is my latest try:

I had the function generating a number in the range of (min + 0.0~0.99999), but I need the range to sometimes reach close to the max or at least up to the middle.

the numbers that will be sent to the function are in the range of;

createRandNum(-2.8,4.8);
createRandNum(-15.0,126.0);


As you can see the range varies.

You guys always have the best solutions.
Thanks for the help,
SjSmile | :)

<br />
double createRandNum(double min, double max){	<br />
	<br />
		 <br />
	    double randomNum= rand();<br />
	<br />
		double p = ((max - min) + randomNum / (max-min));		<br />
		double d = min + (double)rand() / RAND_MAX;<br />
		<br />
		//if(d > max || d < min){<br />
		//	d = (max + min);<br />
		//}<br />
			<br />
		while(count < 100){<br />
			printf("%d\nRandomNum is: ", randomNum);<br />
			printf("%d\nP is: ", p);<br />
			printf("%d\nD is: ", d);<br />
			count++;<br />
		}<br />
		<br />
		return d;		<br />
		 <br />
}

GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
Ryan Binns26-Jun-03 5:29
Ryan Binns26-Jun-03 5:29 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
johnstonsk26-Jun-03 5:42
johnstonsk26-Jun-03 5:42 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
Ian Darling26-Jun-03 6:22
Ian Darling26-Jun-03 6:22 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
David Crow26-Jun-03 7:20
David Crow26-Jun-03 7:20 
GeneralRe: I need AIR & I'm pulling my hair out over Random doubles within a specified range Pin
Ryan Binns26-Jun-03 14:55
Ryan Binns26-Jun-03 14:55 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
johnstonsk27-Jun-03 3:56
johnstonsk27-Jun-03 3:56 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
Ryan Binns27-Jun-03 3:59
Ryan Binns27-Jun-03 3:59 
GeneralRe: I need AIR &amp; I'm pulling my hair out over Random doubles within a specified range Pin
Dominik Reichl26-Jun-03 7:50
Dominik Reichl26-Jun-03 7:50 
GeneralStandard Error and Warning Images Pin
Steve Thresher26-Jun-03 3:31
Steve Thresher26-Jun-03 3:31 
GeneralRe: Standard Error and Warning Images Pin
basementman26-Jun-03 3:54
basementman26-Jun-03 3:54 
GeneralRe: Standard Error and Warning Images Pin
Steve Thresher26-Jun-03 4:35
Steve Thresher26-Jun-03 4:35 
GeneralRe: Standard Error and Warning Images Pin
Ryan Binns26-Jun-03 5:19
Ryan Binns26-Jun-03 5:19 
Generalusing a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 2:52
keegan26-Jun-03 2:52 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
Maximilien26-Jun-03 3:18
Maximilien26-Jun-03 3:18 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 3:27
keegan26-Jun-03 3:27 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
Maximilien26-Jun-03 3:35
Maximilien26-Jun-03 3:35 
GeneralRe: using a vector with CComboBox::AddString() in MFC Pin
keegan26-Jun-03 3:48
keegan26-Jun-03 3:48 

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.