bmandl
Full Member level 4
- Joined
- Feb 26, 2010
- Messages
- 210
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Slovenia
- Activity points
- 3,006
Hello,
I was wondering if there is some way in c++, to compare one integer value to another, but allow tolerance? Something like this:
if (val1 > (val2±x)){...}
else if (val1<(val2±x)){...}
Thank you for your answers!
- - - Updated - - -
Ok, I solved the problem this way:
if (val1 > val2 && abs(val1-val2)>x){...}
else if (val1 < val2 && abs(val1-val2)>x){...}
I was wondering if there is some way in c++, to compare one integer value to another, but allow tolerance? Something like this:
if (val1 > (val2±x)){...}
else if (val1<(val2±x)){...}
Thank you for your answers!
- - - Updated - - -
Ok, I solved the problem this way:
if (val1 > val2 && abs(val1-val2)>x){...}
else if (val1 < val2 && abs(val1-val2)>x){...}