Click here to Skip to main content
15,896,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: character size more than 2 bytes Pin
toxcct8-Dec-04 22:24
toxcct8-Dec-04 22:24 
GeneralRe: character size more than 2 bytes Pin
Thomas Haller9-Dec-04 2:28
Thomas Haller9-Dec-04 2:28 
GeneralRe: character size more than 2 bytes Pin
Henry miller9-Dec-04 5:40
Henry miller9-Dec-04 5:40 
GeneralA CRecordset Problem. Pin
willyfu8-Dec-04 21:01
willyfu8-Dec-04 21:01 
GeneralRe: A CRecordset Problem. Pin
David Crow9-Dec-04 3:16
David Crow9-Dec-04 3:16 
GeneralThank you ,and I have used the ODBC API Pin
willyfu9-Dec-04 18:16
willyfu9-Dec-04 18:16 
GeneralRe: Thank you ,and I have used the ODBC API Pin
David Crow14-Dec-04 3:22
David Crow14-Dec-04 3:22 
QuestionWhat am I doing wrong??? Pin
aaadetos8-Dec-04 20:48
aaadetos8-Dec-04 20:48 
WTF | :WTF: I have a prjt which compiles without errors, but keeps displaying an error message on execution. The error message is only supposed to appear when a certain variable x, is less than or equal to zero. Only one function calls the function that contains this error message. Even after "ensuring" that x has a postive variable, I still get the error message on execution.

My fxn which contains the error message is as follows:
<br />
void ei(double *x, double *expi, int nSize)<br />
{<br />
	enum{nSize = 100};<br />
	const int MAXIT = 100;<br />
	const double EULER=0.577215664901533;<br />
	const double EPS=1e-20;		//note arbitrary value of epsilon<br />
<br />
/*MAXIT is the maximum number of iterations allowed (for speed); <br />
	EULER is Euler's constant, EPS is epsilon, the relative or absolute<br />
	error; */<br />
<br />
	int k;<br />
	double fact[nSize], prev[nSize],sum[nSize],term[nSize];<br />
<br />
	for(int t=0;t<nSize;t++)<br />
	{<br />
		if (x[t]<=0.0)<br />
		{<br />
			AfxMessageBox("x value incorrect, in ei!", MB_OKCANCEL|MB_ICONSTOP);//THIS IS THE ERROR MSG I KEEP GETTING AT RUNTIME.<br />
			exit(1);<br />
		}<br />
<br />
		if (x[t]<EPS)<br />
		{<br />
			expi[t]=log(x[t])+EULER;	//Go ahead and converge!; since x<EPS, anyway<br />
		}<br />
<br />
		if (x[t]<=-log(EPS))<br />
		{<br />
			sum[0]=0.0;<br />
			fact[0]=1.0;<br />
	<br />
			for (k=1;k<MAXIT;k++)<br />
			{<br />
				fact[t] *= x[t]/k;<br />
				term[t]=fact[t]/k;<br />
				sum[t] += term[t];<br />
				if (term[t]<EPS*sum[t]) break;<br />
			}<br />
	<br />
			if (k>MAXIT)<br />
			{<br />
				AfxMessageBox("Series failed in ei!",MB_OKCANCEL|MB_ICONSTOP);<br />
				exit(2);<br />
			}<br />
	<br />
			expi[t]=sum[t]+log(x[t])+EULER;<br />
		}<br />
<br />
		else<br />
		{<br />
			sum[0]=0.0;<br />
			term[0]=1.0;<br />
<br />
			for (k=1;k<MAXIT;k++)<br />
			{<br />
				prev[t]=term[t];<br />
				term[t] *= k/x[t];<br />
<br />
				if (term[t]<EPS) break;<br />
				//since final sum is greater than 1, term itself approximates the relative error<br />
<br />
				if (term[t]<prev[t]) sum[t] += term[t];<br />
<br />
				else<br />
				{<br />
					sum[t] -= prev[t];<br />
					break;<br />
				}<br />
			}<br />
			<br />
			expi[t]=exp(x[t])*(1.0*sum[t])/x[t];<br />
		}<br />
	}<br />
}


the only place where the above function is used is:
<br />
void unbound(double *unbd, int nSize)<br />
{<br />
	enum{nSize = 100};<br />
	double A[nSize],B[nSize],k0[nSize],k1[nSize],s[nSize],expi[nSize],a[nSize],b[nSize];<br />
	<br />
	//trial: K0(x) --> x = rw*sqrt(s), as per A-32<br />
	s[0] = 1;<br />
	for (int t=1;t<nSize;t++)<br />
	{<br />
		double x;//this variable has been initialized in my dialog-control as 1; it is changed by the user at run-time, anyway, and this change is captured in the next 2 lines of code, in the instance of the class, below...<br />
<br />
		CKuchukDlg MyClas;	<br />
		MyClas.m_dWellRad = x;<br />
<br />
		void bessk0(double *x,double *k0,int nSize);<br />
		void bessk1(double *x,double *k1, int nSize);<br />
		void ei(double *x, double *expi, int nSize);<br />
<br />
		s[t] = 2*t*PI;<br />
		a[t] = x*sqrt(s[t]);<br />
		b[t] = 2*sqrt(s[t]);<br />
<br />
		bessk0(a,k0,nSize);<br />
		bessk1(a,k1,nSize);<br />
		ei(b,expi,nSize);<br />
<br />
		A[t] = k0[t]/(x*sqrt(s[t])*k1[t]);<br />
		B[t] = (1-exp(-2*sqrt(s[t])))/(2*sqrt(s[t]));<br />
<br />
		unbd[t]=0.5*(A[t]-B[t]-expi[t]);<br />
	}<br />
}<br />


could someone please tell me where im missing it? Thank you!
Generalfilter all application messages Pin
A T I F8-Dec-04 20:24
A T I F8-Dec-04 20:24 
GeneralRe: filter all application messages Pin
alex.barylski8-Dec-04 20:45
alex.barylski8-Dec-04 20:45 
GeneralPage break in html Pin
Member 12010138-Dec-04 20:05
Member 12010138-Dec-04 20:05 
GeneralRe: Page break in html Pin
alex.barylski8-Dec-04 20:44
alex.barylski8-Dec-04 20:44 
GeneralText Wrap in Static control Pin
Pushkar Tamboli8-Dec-04 19:53
Pushkar Tamboli8-Dec-04 19:53 
GeneralRe: Text Wrap in Static control Pin
A T I F8-Dec-04 20:39
A T I F8-Dec-04 20:39 
GeneralRe: Text Wrap in Static control Pin
Pushkar Tamboli8-Dec-04 22:20
Pushkar Tamboli8-Dec-04 22:20 
GeneralRe: Text Wrap in Static control Pin
namaskaaram8-Dec-04 23:37
namaskaaram8-Dec-04 23:37 
Questioncheck box could be owner draw? Pin
lowiq8-Dec-04 19:51
lowiq8-Dec-04 19:51 
GeneralMarcos in MFC Pin
Amit Mulay8-Dec-04 19:16
Amit Mulay8-Dec-04 19:16 
GeneralRe: Marcos in MFC Pin
alex.barylski8-Dec-04 19:19
alex.barylski8-Dec-04 19:19 
GeneralRe: Marcos in MFC Pin
toxcct8-Dec-04 22:08
toxcct8-Dec-04 22:08 
GeneralPlease clear this doubt Pin
Sreekanth Muralidharan8-Dec-04 16:40
Sreekanth Muralidharan8-Dec-04 16:40 
GeneralPicking transparent color from a gif Pin
Abin8-Dec-04 16:30
Abin8-Dec-04 16:30 
GeneralCMapStringToOb :: lookup() Pin
Anonymous8-Dec-04 16:25
Anonymous8-Dec-04 16:25 
GeneralRe: CMapStringToOb :: lookup() Pin
RChin8-Dec-04 22:42
RChin8-Dec-04 22:42 
GeneralFile dialog Office 2003 style Pin
Gagnon Claude8-Dec-04 16:05
Gagnon Claude8-Dec-04 16:05 

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.