looking for min/max(x,y,z) function

Discussion in 'iPhone/iPad Programming' started by madivad, Apr 3, 2009.

  1. macrumors newbie

    Joined:
    Apr 2, 2009
    #1
    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
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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))...
     
  3. macrumors 68000

    Veldek

    Joined:
    Mar 29, 2003
    Location:
    Germany
    #3
    Even easier would be min(x,y,z) = min(min(x,y),z), wouldn't it?
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Yep, that would work too :)
     
  5. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #5
    Or just write a custom function to do the comparisons.
     
  6. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    MIN and MAX are defined in NSObjCRuntime.h.

    Start there.
     
  7. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #7
    m = a < b ? ( a < c ? a : c ) : ( b < c ? b : c ) ;

    b e n
     
  8. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    If you are using it frequently, set up a #define. Lace with plenty of parentheses, though.
     

Share This Page