AnsweredAssumed Answered

Is 32-bit subtraction with saturation possible?

Question asked by kbrafford on Oct 11, 2010
Latest reply on Oct 15, 2010 by kbrafford

I am using a BF532 and would like to speed up some code that looks like this:

 

unsigned long int counter_array[10];


for (i = 0; i < 10; i++) {

   if (counter_array[i] != 0) {

      counter_array[i]--;

   }

}

 

is there some way I can just do:

   counter_array[i]--;

 

and have it saturate at zero instead of me having to check for it?

 

--Keith Brafford

Outcomes