0

I want to do the saturation function as following:

/* Ensure number is >=0 and <=255 */
#define Saturate(n) ((n) > 0 ? ((n) < 255 ? (n) : 255) : 0)

If 0 < n < 255, return n; if n <= 0, return 0; if n >= 255, return 255.

I am looking for faster way of doing it. For example, is there any built-in function in c which can be used to reduce the number of instructions?

sepp2k
  • 353,842
  • 52
  • 662
  • 667
fluency03
  • 2,459
  • 5
  • 30
  • 60

0 Answers0