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
  • 363,768
  • 54
  • 674
  • 675
fluency03
  • 2,637
  • 7
  • 32
  • 62

0 Answers0