Sign in to follow this  
The C modest god

A phenomena

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
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

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