bmandl
Full Member level 4
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){...}