Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

A phenomena

This topic is 5179 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

I have the following code: if ((CalcLineListPointer.Peek().Point1.Y-MinY)==DeltaY) RadixPosition = LinesList.ObjectsAmount-1; else RadixPosition = floor((Real)(LinesList.ObjectsAmount)*((CalcLineListPointer.Peek().Point1.Y-MinY)/DeltaY)); In debug mode I see that the expression (CalcLineListPointer.Peek().Point1.Y-MinY)==DeltaY is equal to 1, but when I press F10 for step the program performs the else instead of the first expression of the if. Why does it happen?

Share this post


Link to post
Share on other sites
Advertisement
Hello,

(Assuming MinY and DeltaY are floats - if these are integers then I don't see where is the error).

IIRC the float/double precision is different when switching from debug to release in VC++ (nor sure the .NET versions are still affected by that problem but it is definitely the case with VC++6)
The optimization settings are probably the root of this problem but I'm not sure - and you probably don't want to change your compiler settings to resolve the problem. So the solution you might try is to compare (CalcLineListPointer.Peek().Point1.Y-MinY) to DeltaY+epsilon and DeltaY-epsilon [abs((CalcLineListPointer.Peek().Point1.Y-MinY)-DeltaY) < epsilon].

HTH

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!