View Full Version : looking for min/max(x,y,z) function
madivad
Apr 3, 2009, 03: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, 05: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, 06: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, 06:23 AM
Even easier would be min(x,y,z) = min(min(x,y),z), wouldn't it?
Yep, that would work too :)
Eraserhead
Apr 3, 2009, 06:23 AM
Or just write a custom function to do the comparisons.
PhoneyDeveloper
Apr 3, 2009, 10:30 AM
MIN and MAX are defined in NSObjCRuntime.h.
Start there.
lazydog
Apr 3, 2009, 11:13 AM
m = a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ;
b e n
dejo
Apr 3, 2009, 11:26 AM
If you are using it frequently, set up a #define. Lace with plenty of parentheses, though.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.