madivad

Apr 3, 2009, 02:45 AM

does anyone know where there is one for the iPhone? I have searched the docs, and am having all sorts of trouble, I thought this would be a gimme

View Full Version : looking for min/max(x,y,z) function

madivad

Apr 3, 2009, 02:45 AM

does anyone know where there is one for the iPhone? I have searched the docs, and am having all sorts of trouble, I thought this would be a gimme

robbieduncan

Apr 3, 2009, 04:50 AM

I doubt there is a built-in function for these that takes 3 arguments. The standard ones all take two. Of course min(x,y,x) = min(min(x,y),min(x,z))...

Veldek

Apr 3, 2009, 05:14 AM

I doubt there is a built-in function for these that takes 3 arguments. The standard ones all take two. Of course min(x,y,x) = min(min(x,y),min(x,z))...Even easier would be min(x,y,z) = min(min(x,y),z), wouldn't it?

robbieduncan

Apr 3, 2009, 05:23 AM

Even easier would be min(x,y,z) = min(min(x,y),z), wouldn't it?

Yep, that would work too :)

Yep, that would work too :)

Eraserhead

Apr 3, 2009, 05:23 AM

Or just write a custom function to do the comparisons.

PhoneyDeveloper

Apr 3, 2009, 09:30 AM

MIN and MAX are defined in NSObjCRuntime.h.

Start there.

Start there.

lazydog

Apr 3, 2009, 10:13 AM

m = a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ;

b e n

b e n

dejo

Apr 3, 2009, 10:26 AM

If you are using it frequently, set up a #define. Lace with plenty of parentheses, though.