min and max?

Hello,

I can’t believe I didn’t find the answer to this yet, but how do you do a min(v1, v2) or max(v1, v2) in C++? I am currently using the >? and <? operators, but the compiler is telling me they are deprecated.

Thanks!

I think we have min and max defined in ofConstants as doing just what you need to do. try it out

int maxVal = max(2,10); (might be uppercase MAX)

:slight_smile:

pretty much the same way

v = MIN(v1,v2);
v = MAX(v1,v2);

these are #defined in ofConstants.h.

ah caps, that’s why it wasn’t working… thanks!