Sign in to follow this  

Floats, Lists = Problem

This topic is 3199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all sorry for the vuage header but I did not really know what to put for it. Problem in a nutshell, I print out the value which I return from a class which is stored in a list and it says its value is 0.0000f then right after I print out the value I have a IF statement which checks if the float value is <= to 0. But the code in the if statement does not get executed!?! To add insult to injury I also do the same for a class that two elements behind it, it prints out zero, and enters the if statement. Does ant one know whats going on. I declare the list and the itterators like this
list<class CFuzzLLineMF> m_listMembershipFuncCtnr;
list<class CFuzzLLineMF>::iterator m_PrevlistIterMembershipFuncCtnr;
list<class CFuzzLLineMF>::iterator m_listIterMembershipFuncCtnr;
list<class CFuzzLLineMF>::iterator m_NextlistIterMembershipFuncCtnr;

then later in the code in a for loop i do this
	for(int i = 0; i < (m_iMaxNumberOfMF-1); i++)
	{
		if( i > 0)
		{
			m_PrevlistIterMembershipFuncCtnr = m_listMembershipFuncCtnr.begin();
			advance(m_PrevlistIterMembershipFuncCtnr,(i-1));
		}

		m_listIterMembershipFuncCtnr = m_listMembershipFuncCtnr.begin();
		advance(m_listIterMembershipFuncCtnr,i);

		if(i < (m_iMaxNumberOfMF-1))
		{
			m_NextlistIterMembershipFuncCtnr = m_listMembershipFuncCtnr.begin();
			advance(m_NextlistIterMembershipFuncCtnr,(i+1));
		}



		if(( i > 0) && (i < (m_iMaxNumberOfMF-1)))
		{
			
			if(i == 1)
			{
				char Test[256];

				sprintf_s(Test,sizeof(Test),"%f",m_PrevlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f());
				MessageBox(NULL,Test,"m_PrevlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f",NULL);

				sprintf_s(Test,sizeof(Test),"%f",m_listIterMembershipFuncCtnr->Rtn_MembershipDegree_f());
				MessageBox(NULL,Test,"m_listIterMembershipFuncCtnr->Rtn_MembershipDegree_f",NULL);

				sprintf_s(Test,sizeof(Test),"%f",m_NextlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f());
				MessageBox(NULL,Test,"m_NextlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f",NULL);

				if(m_PrevlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() <= FLT_EPSILON)
				{
					MessageBox(NULL,"Prev",NULL,NULL);
				}


				if(m_NextlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() <= FLT_EPSILON)
				{
					MessageBox(NULL,"Next",NULL,NULL);
				}
			}
		}
	}


When the code gets executed m_PrevlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() returns 0.0f which gets displayed in the message box, m_listIterMembershipFuncCtnr->Rtn_MembershipDegree_f() returns 1.0f and m_NextlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() returns 0.0f in the if statement where i check if the value from m_PrevlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() is <= to Zero it acknowledges tha values as being Zero and dislays the message box, but it does not with the value returned from m_NextlistIterMembershipFuncCtnr->Rtn_MembershipDegree_f() any ideas whats up?

Share this post


Link to post
Share on other sites

This topic is 3199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this