-
June 13th, 2009, 05:55 AM
#1
Double compare operation not assigned correctly
This is my first thread so bear with me...
I have a comparison operation between two doubles:
code:
Code:
1. double lowX= low.X // value is 2800000.000
2. double highX= high.X // value is 2872000.000
3. bool result = lowX <= highX // result false.
4. result = lowX <= highX // result true.
And no matter what is the value of the doubles the result is false.
Now the weird part is that if I use a VS7 immediate window and evalute "lowX <= highX" the result is true.
If I have a break point and move the running line (yellow arrow) for the SECOND time on line 3 it also becomes true.
I think that result is the first bool assignment in the code because other bool operation in later parts of the code works just fine.
I am afraid there is something wrong with the stack. (Maybe the result doesn't really assigned to the bool result), But have no clue how to approach it.
Thanks in Advance
-
June 13th, 2009, 10:58 AM
#2
Re: Double compare operation not assigned correctly
your code is incomplete. What type is low.X and high.X? This code below compiles and returns the expected results:
Code:
double lowX= 2800000.000;
double highX= 2872000.000;
bool result = lowX <= highX; //true
result = lowX <= highX; //true
result = highX <= lowX; //false
Please include exact code that cause your behavior. what you've posted works fine.
-
June 13th, 2009, 03:26 PM
#3
Re: Double compare operation not assigned correctly
low and high are essentially
Code:
struct point
{
double x;
double y;
}
I will try to post the complete code
but the general idea is like this
Code:
box::box(const point low, const point high)
{
ASSERT(low.x <= high.x);
ASSERT(low.y <= high.y);
}
While I checked the problem i broke it down to my previous post...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|