Click here to Skip to main content
15,921,452 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Text editing app with special objects Pin
PaulFrazee26-Jun-03 17:33
PaulFrazee26-Jun-03 17:33 
GeneralRe: Text editing app with special objects Pin
Ryan Binns26-Jun-03 18:08
Ryan Binns26-Jun-03 18:08 
GeneralRe: Text editing app with special objects Pin
PaulFrazee27-Jun-03 4:04
PaulFrazee27-Jun-03 4:04 
GeneralRe: Text editing app with special objects Pin
Ryan Binns27-Jun-03 4:12
Ryan Binns27-Jun-03 4:12 
GeneralRe: Text editing app with special objects Pin
PaulFrazee27-Jun-03 5:19
PaulFrazee27-Jun-03 5:19 
GeneralRe: Text editing app with special objects Pin
Ryan Binns27-Jun-03 5:21
Ryan Binns27-Jun-03 5:21 
GeneralJust learning STL.. easy question.. Pin
RobJones26-Jun-03 6:33
RobJones26-Jun-03 6:33 
GeneralRe: Just learning STL.. easy question.. Pin
keegan26-Jun-03 6:37
keegan26-Jun-03 6:37 
GeneralRe: Just learning STL.. easy question.. Pin
John M. Drescher26-Jun-03 6:39
John M. Drescher26-Jun-03 6:39 
GeneralRe: Just learning STL.. easy question.. Pin
RobJones26-Jun-03 6:56
RobJones26-Jun-03 6:56 
GeneralRe: Just learning STL.. easy question.. Pin
John M. Drescher26-Jun-03 7:14
John M. Drescher26-Jun-03 7:14 
Generalanother quick question.. Pin
RobJones26-Jun-03 8:37
RobJones26-Jun-03 8:37 
GeneralRe: another quick question.. Pin
John M. Drescher26-Jun-03 8:52
John M. Drescher26-Jun-03 8:52 
GeneralRe: another quick question.. Pin
RobJones26-Jun-03 9:14
RobJones26-Jun-03 9:14 
GeneralRe: another quick question.. Pin
CyberDen26-Jun-03 9:36
CyberDen26-Jun-03 9:36 
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 

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.