I have a code with pixel brightness that is limited to [0..255]. And it's evaluated for some reason, so I can get value outside the bounds. I can do
(if x>maxValue) x = maxValue;
or
x = min(x, MaxValue);
or
(x > MaxValue) ? MaxValue : x;
but I wonder what is the nice way? How to limit a value with less comparisons and with good code style?