We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
There a two unsigned integers. Lets call them red and blue. How can i put them in a if condition?
The if condition should be true, if the difference between the two (unsigned integer) variables is greater than a constant value?
I assume i should use the labs function in such way:
if (labs((signed int)red - (signed int)blue) > 22){ // doing something if condition is true :-) }
is there a better way to do?
In which library is the labs function? Thanks in advance for being patient ;-)
Critisism is not only allowed, but wanted
This might be simpler and avoid any unpleasant surprises:
unsigned int diff; if(red > blue) { diff=red-blue; } else { diff=blue-red; } if(diff > x) { //Do this } else { //Do that }